# Problem with REXML

**URL:** <https://www.ruby-forum.com/t/problem-with-rexml/104962>\
**Category:** Ruby\
**Created:** [May 24, 2007, 11:46am UTC](https://www.ruby-forum.com/t/problem-with-rexml/104962 "2007-05-24T11:46:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [May 24, 2007, 11:46am UTC](https://www.ruby-forum.com/t/problem-with-rexml/104962/1 "2007-05-24T11:46:47Z")

</div>

I have a problem when reading out strings from xml documents. The  
problem is that special characters such as Ã¥Ã¤Ã¶ comes out wierd. When  
reading these characters from text files the problem doesn’t exist. Can  
someone explain whay this is and, if possible, how I can fix it?

Thanks  
Jim

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [May 24, 2007, 11:58am UTC](https://www.ruby-forum.com/t/problem-with-rexml/104962/2 "2007-05-24T11:58:01Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

What are the file encodings? Do the text files have a different  
encoding than the xml ones?

George

On 24 May 2007, at 10:46, Jim Kr wrote:

> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFGVWFmuHSlGoVGf7URAq+IAJ0d0BY5jANt7F9ekzsRl0+G2k1eVgCfTdMj  
m242ynUYCnlAXVU5BMuJt64=  
=zCcu  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [May 24, 2007, 12:52pm UTC](https://www.ruby-forum.com/t/problem-with-rexml/104962/3 "2007-05-24T12:52:04Z")

</div>

George M. wrote:

> -----BEGIN PGP SIGNED MESSAGE-----  
> Hash: SHA1
> 
> What are the file encodings? Do the text files have a different  
> encoding than the xml ones?
> 
> George
> 
> On 24 May 2007, at 10:46, Jim Kr wrote:
> 
> > –  
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> -----BEGIN PGP SIGNATURE-----  
> Version: GnuPG v1.4.1 (Darwin)
> 
> iD8DBQFGVWFmuHSlGoVGf7URAq+IAJ0d0BY5jANt7F9ekzsRl0+G2k1eVgCfTdMj  
> m242ynUYCnlAXVU5BMuJt64=  
> =zCcu  
> -----END PGP SIGNATURE-----

The XML file is encoded with ISO-8859-1 while the text files are Windows  
.txt files (for which I don’t have a clue what encoding they use)

Jim

---

<div class="post-metadata">

**Author:** ![bigjimmyk3](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/6de8d8/32.png) [@bigjimmyk3](https://www.ruby-forum.com/u/bigjimmyk3)\
**Post date:** [May 24, 2007, 1:22pm UTC](https://www.ruby-forum.com/t/problem-with-rexml/104962/4 "2007-05-24T13:22:10Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

It might help if you try saving the files as UTF-8 and then add:

$KCODE = ‘u’  
require ‘jcode’

in your script.

George

> The XML file is encoded with ISO-8859-1 while the text files are  
> Windows  
> .txt files (for which I don’t have a clue what encoding they use)
> 
> Jim
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFGVXU1uHSlGoVGf7URAtSlAJ9yFzLYm79thv4xvqaV3SJKjUhDgQCePpbh  
XfBEVicn9lz1/9o65UkggoM=  
=o5GF  
-----END PGP SIGNATURE-----
