How to load code converters?

O

O01eg Oleg

When I try to encode string in program I got
Encoding::ConverterNotFoundError error "code converter not found (UTF-8
to KOI8-R)" (and other charsets)
When I run script with encoding in ruby interpreter it work.
What I have to call for loading converters?
 
C

Caleb Clausen

When I try to encode string in program I got
Encoding::ConverterNotFoundError error "code converter not found (UTF-8
to KOI8-R)" (and other charsets)
When I run script with encoding in ruby interpreter it work.
What I have to call for loading converters?

might be:
require 'enc/koi8_r'
 
O

O01eg Oleg

Caleb said:
might be:
require 'enc/koi8_r'

Ruby 1.9
Also, it doesn't work and I don't see file for cp866 charset.
transcoder table from my program:
(gdb)p *transcoder_table
$3 = {type = 0x7ffff75632c0, num_bins = 11, entries_packed = 0,
num_entries = 1, bins = 0x704170, head = 0x7077b0, tail = 0x7077b0}

transcoder table from ruby interpreter:
(gdb) p *transcoder_table
$2 = {type = 0x7ffff7dc32c0, num_bins = 19, entries_packed = 0,
num_entries = 84, bins = 0x73e190, head = 0x6cc600, tail = 0x741150}
 
C

Caleb Clausen


Did you try my suggestion or not?

It might help if you could post the exact ruby version. (what does
ruby -v output?)
Also, it doesn't work and I don't see file for cp866 charset.

"it doesn't work" gives me very little information to go on. What doesn't work?

Please post a (hopefully short!) script which demonstrates the problem
you're having.

I don't see any mention of a cp866 charset in ruby sources, so you
might just be SOL there.
transcoder table from my program:
(gdb)p *transcoder_table
$3 = {type = 0x7ffff75632c0, num_bins = 11, entries_packed = 0,
num_entries = 1, bins = 0x704170, head = 0x7077b0, tail = 0x7077b0}

transcoder table from ruby interpreter:
(gdb) p *transcoder_table
$2 = {type = 0x7ffff7dc32c0, num_bins = 19, entries_packed = 0,
num_entries = 84, bins = 0x73e190, head = 0x6cc600, tail = 0x741150}

Looks like this table gets added to by encoding-related extensions, so
you might have to require them before it gets the stuff you want in
it.
 
O

O01eg Oleg

Caleb said:
Did you try my suggestion or not?

Yes, but as I say, it doesn't help me.
It might help if you could post the exact ruby version. (what does
ruby -v output?)

ruby 1.9.3dev (2010-05-24 trunk 27986) [x86_64-linux]
"it doesn't work" gives me very little information to go on. What
doesn't work?

I got described error when try to encode string from UTF-8 to CP866,
CP1251 and KOI8-R charset.
Please post a (hopefully short!) script which demonstrates the problem
you're having.

# encoding: utf-8
puts "привет".encode(Encoding::IBM866)
puts "привет".encode(Encoding::CP1251)
puts "привет".encode(Encoding::KOI8_R)
Looks like this table gets added to by encoding-related extensions, so
you might have to require them before it gets the stuff you want in
it.
Yes, I found this. Table fill by Init_transdb in "enc/trans/transdb.so".
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top