how to use csv to open file in gbk code

Discussion in 'Ruby' started by Pen Ttt, Apr 16, 2010.

  1. Pen Ttt

    Pen Ttt Guest

    there is an file(/home/pt/test/shbase.csv) in gbk not utf-8,the
    following is my progrmm:
    require 'csv'
    CSV.open('/home/pt/test/shbase.csv', 'r') do |row|
    while line=row.gets
    puts line
    end
    end
    wrong message:
    /usr/local/ruby/lib/ruby/1.9.1/csv.rb:1988:in `=~': invalid byte
    sequence in UTF-8 (ArgumentError)
    how to open it use csv?
    --
    Posted via http://www.ruby-forum.com/.
    Pen Ttt, Apr 16, 2010
    #1
    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. Replies:
    4
    Views:
    982
  2. Steven Bethard

    elementtree and gbk encoding

    Steven Bethard, Mar 14, 2006, in forum: Python
    Replies:
    12
    Views:
    1,008
    Steven Bethard
    Mar 15, 2006
  3. higer
    Replies:
    10
    Views:
    882
    higer
    Jun 8, 2009
  4. Pen Ttt
    Replies:
    0
    Views:
    168
    Pen Ttt
    Apr 15, 2010
  5. Stanley Xu
    Replies:
    2
    Views:
    609
    Stanley Xu
    Mar 23, 2011
Loading...

Share This Page