oracle oci8 utf8 corruption

C

ciapecki

I have a small script oci1.rb:

require 'oci8'
conn = OCI8.new("test","test","test_db")
File.open("out.txt","wb") do |out|
tabs = conn.exec('SELECT * from test_utf8') do |r|
out.write(r.join(','))
out.write("\n")
end
end
conn.logoff

that runs perfectly on windows producing from my test_db:
polish,łóśżć
russsian,фывафыва
german,äöü

when I run exactly the same on my linux box:
polish,loszc
russsian,????????
german,aou

I tested then a small script that reads and writes UTF8 on linux
(read_write_utf8.rb):
File.open("utf8_out.txt","wb") do |out|
File.open("utf8.txt","r").each do |line|
out.write(line)
end
end

and that works good!

chris@emeadb:~/work/ruby/oci$ ruby read_write_utf8.rb

chris@emeadb:~/work/ruby/oci$ cat utf8.txt
polish,łóśżć
russsian,фывафыва
german,äöü

chris@emeadb:~/work/ruby/oci$ cat utf8_out.txt
polish,łóśżć
russsian,фывафыва
german,äöü

where should I try to dig into to find out how to force the oracle
database data to be properly stored in the file on linux?
I just add that
LANG=en_US.UTF-8

thanks,
chris
 
K

krzysztof cierpisz

I have a small script oci1.rb:

require 'oci8'
conn = OCI8.new("test","test","test_db")
File.open("out.txt","wb") do |out|
  tabs = conn.exec('SELECT * from test_utf8') do |r|
     out.write(r.join(','))
     out.write("\n")
  end
end
conn.logoff

that runs perfectly on windows producing from my test_db:
polish,łóśżć
russsian,фывафыва
german,äöü

when I run exactly the same on my linux box:
polish,loszc
russsian,????????
german,aou

I tested then a small script that reads and writes UTF8 on linux
(read_write_utf8.rb):
File.open("utf8_out.txt","wb") do |out|
  File.open("utf8.txt","r").each do |line|
    out.write(line)
  end
end

and that works good!

chris@emeadb:~/work/ruby/oci$ ruby read_write_utf8.rb

chris@emeadb:~/work/ruby/oci$ cat utf8.txt
polish,łóśżć
russsian,фывафыва
german,äöü

chris@emeadb:~/work/ruby/oci$ cat utf8_out.txt
polish,łóśżć
russsian,фывафыва
german,äöü

where should I try to dig into to find out how to force the oracle
database data to be properly stored in the file on linux?
I just add that
LANG=en_US.UTF-8

thanks,
chris

apparently setting NLS_LANG=AMERICAN_AMERICA.UTF8 (externally! - not
in the ruby script) did the trick.

chris
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top