What about charset?

Discussion in 'Ruby' started by Noé Alejandro, May 5, 2010.

  1. 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/.
     
    Noé Alejandro, May 5, 2010
    #1
    1. Advertising

  2. 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/.
     
    Brian Candler, May 5, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Efy.
    Replies:
    2
    Views:
    1,119
  2. Sasha Shevelev

    Re: Displaying Charset windows-1251

    Sasha Shevelev, Jul 2, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    3,171
    Sasha Shevelev
    Jul 2, 2003
  3. Calvin Lai
    Replies:
    6
    Views:
    21,027
    Joerg Jooss
    Dec 31, 2003
  4. Guest
    Replies:
    0
    Views:
    587
    Guest
    Feb 20, 2004
  5. optimistx

    javascript charset <> page charset

    optimistx, Aug 14, 2008, in forum: Javascript
    Replies:
    2
    Views:
    305
    optimistx
    Aug 15, 2008
Loading...

Share This Page