Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > What about charset?

Reply
Thread Tools

What about charset?

 
 
Noé Alejandro
Guest
Posts: n/a
 
      05-05-2010
Hi!

I have a ruby program wich take some information from a .txt file, and
copy it to a sqlite3 table. But the text is in ASCII-8BIT charset, so
when I select the data from the table, it doesn't return the right
characters. What can I do?

Thanks.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      05-05-2010
Noé Alejandro wrote:
> I have a ruby program wich take some information from a .txt file, and
> copy it to a sqlite3 table. But the text is in ASCII-8BIT charset, so
> when I select the data from the table, it doesn't return the right
> characters. What can I do?


Show your code, and also which exact versions of ruby, ruby-sqlite3 and
operating system you are using.

Are you sure it doesn't "return the right characters"? How do you know?
Use str.bytes.to_a to be sure, which will show you the actual byte
codes, and compare this str.bytes.to_a for the strings you put into the
database.

Any data you put into sqlite3 should be returned the same. The string
you get back from sqlite3 might be tagged with the wrong encoding (in
ruby 1.9), but it should at least be the same string of bytes.
Furthermore the encoding tag shouldn't affect how they are displayed, at
least if you're using a regular "puts" to write them out, and haven't
started messing with external encoding settings.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments