libxml utf-8 locale

M

Mage

Hello,

honestly if I was to select two things I hate about computers, they=20
should be XML and UTF-8.

I have an xml file:

"<?xml version=3D'1.0' encoding=3D'UTF-8'?>...."

I have installed libxml-ruby and liblocale-ruby on my etch debian.

I have tried:
export LANG=3Dhu_HU.UTF-8
kate sample.xml
it opens the file correctly.

I have tried
export LANG=3Dhu_HU.UTF-8
my_script.rb sample.xml

It cannot deal with the UTF chars. I also have tried insert this line=20
into my script (with require 'locale' of course):
Locale.setlocale(Locale::LC_ALL, 'hu_HU.UTF-8')

No effect.

My script is similar to the one in the docs:

require 'xml/libxml'
doc =3D XML::Document.file('output.xml')
root =3D doc.root

puts "Root element name: #{root.name}"

elem3 =3D root.find('elem3').to_a.first
puts "Elem3: #{elem3['attr']}"

doc.find('//root_node/foo/bar').each do |node|
puts "Node path: #{node.path} \t Contents: #{node}"
end


(I am not using this but something like that with setlocale.)

The output is filled with:
K=C3=83=C2=ADn=C3=83=C2=A1l


What to do now?

Mage
 
L

Logan Capaldo

Hello,

honestly if I was to select two things I hate about computers, they =20=
should be XML and UTF-8.

I have an xml file:

"<?xml version=3D'1.0' encoding=3D'UTF-8'?>...."

I have installed libxml-ruby and liblocale-ruby on my etch debian.

I have tried:
export LANG=3Dhu_HU.UTF-8
kate sample.xml
it opens the file correctly.

I have tried
export LANG=3Dhu_HU.UTF-8
my_script.rb sample.xml

It cannot deal with the UTF chars. I also have tried insert this =20
line into my script (with require 'locale' of course):
Locale.setlocale(Locale::LC_ALL, 'hu_HU.UTF-8')

No effect.

My script is similar to the one in the docs:

require 'xml/libxml'
doc =3D XML::Document.file('output.xml')
root =3D doc.root

puts "Root element name: #{root.name}"

elem3 =3D root.find('elem3').to_a.first
puts "Elem3: #{elem3['attr']}"

doc.find('//root_node/foo/bar').each do |node|
puts "Node path: #{node.path} \t Contents: #{node}"
end


(I am not using this but something like that with setlocale.)

The output is filled with:
K=C3 n=C3=A1l


What to do now?

Mage

Have you tried putting
$KCODE=3Du
at the top of your script? (possibly before any requires.)
 
M

Mage

Logan said:
Hello,

honestly if I was to select two things I hate about computers, they=20
should be XML and UTF-8.

I have an xml file:

"<?xml version=3D'1.0' encoding=3D'UTF-8'?>...."

I have installed libxml-ruby and liblocale-ruby on my etch debian.

I have tried:
export LANG=3Dhu_HU.UTF-8
kate sample.xml
it opens the file correctly.

I have tried
export LANG=3Dhu_HU.UTF-8
my_script.rb sample.xml

It cannot deal with the UTF chars. I also have tried insert this line=20
into my script (with require 'locale' of course):
Locale.setlocale(Locale::LC_ALL, 'hu_HU.UTF-8')

No effect.

My script is similar to the one in the docs:

require 'xml/libxml'
doc =3D XML::Document.file('output.xml')
root =3D doc.root

puts "Root element name: #{root.name}"

elem3 =3D root.find('elem3').to_a.first
puts "Elem3: #{elem3['attr']}"

doc.find('//root_node/foo/bar').each do |node|
puts "Node path: #{node.path} \t Contents: #{node}"
end


(I am not using this but something like that with setlocale.)

The output is filled with:
K=C3=83 n=C3=83=C2=A1l


What to do now?

Mage

Have you tried putting
$KCODE=3Du
at the top of your script? (possibly before any requires.)

Didn't help.

Now I am using iconv converter for some nodes, but I think it's a nasty w=
ay.

Mage
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top