[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

trouble with rexml

hongseok.yoon

2/22/2006 7:58:00 AM

I read XML file using REXML.
The XML file contains Korean charactors.

If I print the file using REXML::Document.write $stdout, everything is
okay.( means Korean is printed out narmaly )
But, if I try again using REXML::Element.text, Korean charactors are
broken.( some strange charactors )

ARe there any solution for this?

4 Answers

Gyoung-Yoon Noh

2/22/2006 2:06:00 PM

0

On 2/22/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:> I read XML file using REXML.> The XML file contains Korean charactors.>> If I print the file using REXML::Document.write $stdout, everything is> okay.( means Korean is printed out narmaly )> But, if I try again using REXML::Element.text, Korean charactors are> broken.( some strange charactors )>> ARe there any solution for this?>What encoding scheme did you use?Show me the content of Element.text.--http://nohmad.su...

TAKANO Noriyuki

2/22/2006 11:54:00 PM

0

Gyoung-Yoon Noh wrote:

>On 2/22/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:
>
>
>>I read XML file using REXML.
>>The XML file contains Korean charactors.
>>
>>If I print the file using REXML::Document.write $stdout, everything is
>>okay.( means Korean is printed out narmaly )
>>But, if I try again using REXML::Element.text, Korean charactors are
>>broken.( some strange charactors )
>>
>>ARe there any solution for this?
>>
>>
>>
>
>What encoding scheme did you use?
>Show me the content of Element.text.
>
>--
>http://nohmad.su...
>
>
Dear Yoon,

Noh might have already helped you out and my suggestion here may not be
relevant, but I wonder what method, e.g. puts, print or p, you used to
print the return of element.text. The element.text method only returns
text data but doesn't print. (You can see something on the console if
you are using something interactive, but it may not appear as the string
you expected.)

Have you tried like these lines?
$stdout.puts element.text
and
$stdout.puts element.to_s
The $stdout.puts method shows the character string obtained from the
object (the return value of element.text or element.to_s in the cases
above).
Some others like
p element.text
may not show the string you expected, but it does show a representation
of the object which is not necessarily a character string.

cheers,
nori



hongseok.yoon

2/23/2006 1:26:00 AM

0

I think it may be a problem of REXML.
If I print [element].to_s, the string is already broken.

Are there another XML library for RUBY?

Gyoung-Yoon Noh

2/23/2006 6:27:00 AM

0

On 2/23/06, hongseok.yoon@gmail.com <hongseok.yoon@gmail.com> wrote:> I think it may be a problem of REXML.> If I print [element].to_s, the string is already broken.>> Are there another XML library for RUBY?>>>What did they look like? Show the result of "p element", for example:irb(main):011:0> puts Iconv.iconv('utf-8', 'euc-kr', "\267\347\272\361").first???=> nilirb(main):012:0> p Iconv.iconv('utf-8', 'euc-kr', "\267\347\272\361").first"\353\243\250\353\271\204"=> nilAnyone who willing to reply your question, need to see theinternal representation of the broken strings like latter form.Actually, that's not broken. Don't lose hope. :)--http://nohmad.su...