Closed strny closed 14 years ago
Hi, Pavel. Have you tried another lib. I'm having no problems with nokogiri and / or rexml as my xml libs and Russian stored in utf-8 in my mysql
Pavel, I just confirmed on my machine. It looks like you are using polish, hungarian or chek? Right? I tried with russian on a windows machine. Using nokogiri as my backend lib.
My test:
require 'roxml'
class TestResult
include ROXML
xml_accessor :message
end
def test
res = TestResult.new
res.message = "sadfk одловыа jjklsd " #random russian and english charecters
res.to_xml
end
@test_string = test
@utf_xml = @test_string.serialize(:encoding => 'UTF-8', :save_with => :as_xml)
File.open("test.xml","w") do |f|
f << @utf_xml
end
This produces an xml file - that is properly formatted and encoded. However if you run the same in irb - and take a look that the internal of that xml element - you will see that it actually holds mapped values corresponding to utf values of those characters. I hope that makes sense. :-)
Thank you for your answer. I found that I used old version of ROXML (2.5.3), new version is working well.
Glad you folks worked this out. I've got tests on this now (if I didn't in the past) to ensure roxml doesn't regress in the future.
Glad to help :-) You created a great library!
I've created this simple class: class TestResult include ROXML xml_accessor :message end
My controller code looks like this: def test res = TestResult.new res.message = "Žlutý kůň" respond_to do |format| format.xml {render :xml=>res.to_xml} end end Output in a browser is (UTF-8): <testresult>
Output should be:
I am using libxml. Thanks. Pavel