What about charset?

  • Thread starter Noé Alejandro
  • Start date
N

Noé Alejandro

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.
 
B

Brian Candler

Noé Alejandro said:
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.
 

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,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top