Prev: How to suggest Kernel#printf to add a note to see sprintf
Next: [ANN] posix_mq 0.5.0 - POSIX Message Queues for Ruby
From: Noé Alejandro on 4 May 2010 22:04 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/.
From: Brian Candler on 5 May 2010 15:11
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/. |