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 )
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.
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.
Anyone who willing to reply your question, need to see the
internal representation of the broken strings like latter form.
Actually, that’s not broken. Don’t lose hope.