level 9
sevk
楼主
#!/usr/bin/env ruby -w
# coding: utf-8
require 'pathname'
#require 'rchardet'
require 'iconv'
class String
def to_gb
Iconv.conv("gb2312//IGNORE","UTF-8//IGNORE",self)
end
def utf8_to_gb
Iconv.conv("gb2312//IGNORE","UTF-8//IGNORE",self)
end
def gb_to_utf8
Iconv.conv("UTF-8//IGNORE","GB18030//IGNORE",self)
end
def to_utf8
Iconv.conv("UTF-8//IGNORE","GB18030//IGNORE",self)
end
end
2010年08月26日 01点08分
1
# coding: utf-8
require 'pathname'
#require 'rchardet'
require 'iconv'
class String
def to_gb
Iconv.conv("gb2312//IGNORE","UTF-8//IGNORE",self)
end
def utf8_to_gb
Iconv.conv("gb2312//IGNORE","UTF-8//IGNORE",self)
end
def gb_to_utf8
Iconv.conv("UTF-8//IGNORE","GB18030//IGNORE",self)
end
def to_utf8
Iconv.conv("UTF-8//IGNORE","GB18030//IGNORE",self)
end
end