Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > how to use csv to open file in gbk code

Reply
Thread Tools

how to use csv to open file in gbk code

 
 
Pen Ttt
Guest
Posts: n/a
 
      04-16-2010
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/.

 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to use String.split to split a mixed encoding string(partencoded in gbk, part encoded in utf-8) Stanley Xu Ruby 2 03-23-2011 02:06 PM
transfer GBK into UTF-8 in csv file Pen Ttt Ruby 0 04-15-2010 01:49 PM
how to transfer my utf8 code saved in a file to gbk code higer Python 10 06-08-2009 06:15 AM
Source Encoding GBK/GB2312 steven@lczmsoft.com Python 4 02-26-2005 06:03 AM



Advertisments