[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Prevent REXML from doing any character decoding

helzer

9/21/2007 1:28:00 PM

How can I ask REXML to NOT DO any sort of character decoding or
encoding when it processes XML files?
My files include all sorts of encoding, which is unfortunately not
recognized by REXML. I just want to process it so that all characters
are maintained exactly as they are.

For example, Unicode HTML encoded characters (like  ) should just
stay this sequence, and not transformed into Â.

It it possible?
Can I do this without adding a character encoding line to the XML
files?

Thanks,
Helzer

1 Answer

Jano Svitok

9/21/2007 3:05:00 PM

0

On 9/21/07, helzer <amir.helzer@gmail.com> wrote:
> How can I ask REXML to NOT DO any sort of character decoding or
> encoding when it processes XML files?
> My files include all sorts of encoding, which is unfortunately not
> recognized by REXML. I just want to process it so that all characters
> are maintained exactly as they are.
>
> For example, Unicode HTML encoded characters (like &#160;) should just
> stay this sequence, and not transformed into Â.
>
> It it possible?
> Can I do this without adding a character encoding line to the XML
> files?
>
> Thanks,
> Helzer

http://www.germane-software.com/software/rexml/docs/tut... :

There is a programmatic solution: :raw. If you set the :raw flag on
any Text or Element node, the entities within that node will not be
processed. This means that you'll have to deal with entities yourself:

Entity Replacement

doc = Document.new('<!DOCTYPE
foo [ <!ENTITY ent "replace"> ]><a>replace
&ent;</a>',{:raw=>:all})
doc.root.text #-> "replace &ent;" doc.to_s # Generates: #
<!DOCTYPE foo [ # <!ENTITY ent "replace"> #
]><a>replace &ent;</a>