(I'm not sure, whether you read this on [email protected] already ...)



Hi, there,

I want to read a file (a Google mail address book as CSV), encoded as UTF-16LE.
I want to treat it within my ruby script as UTF-8.

To demonstrate that, I created a few lines of ruby code, that you find below.

The encoding of the line, that I read from that file,
should be identical to the "internal_encoding" of that file,
do you agree?

That works fine with ruby-1.9.2-p180,
but it doesn't work properly with "jruby-1.6.0.RC2 --1.9".

It this something worth fixing with jruby ("--1.9")?

Or am I doing something wrong?

J.

======================================================================
#

# $ ~/.rvm/bin/jruby-1.6.0.RC2 --1.9 -w test-utf.01.rb
# $ ~/.rvm/bin/ruby-1.9.2-p180       -w test-utf.01.rb 

f = open('google.UTF-16LE.csv', "r:UTF-16LE:UTF-8")

STDERR.printf("=%d: %s=>{%s},%s=>{%s} // %s\n",__LINE__,
              'f.external_encoding',f.external_encoding,
              'f.internal_encoding',f.internal_encoding,
              '...')

line_1 = f.gets

STDERR.printf("=%d: %s=>{%s} // %s\n",__LINE__,
              'line_1.encoding.name',line_1.encoding.name,
              '...')

# $ ~/.rvm/bin/ruby-1.9.2-p180 -w test-utf.01.rb 
# =8: f.external_encoding=>{UTF-16LE},f.internal_encoding=>{UTF-8} // ...
# =15: line_1.encoding.name=>{UTF-8} // ...

# $ $HOME/.rvm/bin/jruby-1.6.0.RC2 --1.9 -w test-utf.01.rb 
# =8: f.external_encoding=>{UTF-16LE},f.internal_encoding=>{UTF-8} // ...
# =15: line_1.encoding.name=>{UTF-16LE} // ...


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to