Project

General

Profile

Actions

Bug #1965

closed

the strange thing in Iconv under windows(GBK)

Added by phoenix (junchen wu) over 14 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32]
Backport:
[ruby-core:24990]

Description

=begin
I have a file encoding in utf-8,this is the content:

#掉
config

I read it and then match it with =~/ab/,it will raise: ArgumentError: invalid byte sequence in GBK.
There is something strange:
irb> s=IO.readlines('test.utf8').join
=> "#鎺\x89\nconfig"
irb> gbk=Iconv.conv('gbk','utf-8',s)
=> "#掉\nconfig"
irb> utf=Iconv.conv('utf-8','gbk',gbk)
=> "#鎺塡nconfig"
irb> s==utf
=> false # in Ruby1.8.7,it will say true
irb> s=~/ab/
ArgumentError: invalid byte sequence in GBK
irb> utf=~/ab/
=> nil

my environment:
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32]
Windows XP,GBK,chcp=>936
=end


Files

test.utf8 (12 Bytes) test.utf8 the utf-8 encoding string file phoenix (junchen wu), 08/20/2009 04:43 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0