1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/nkf/lib/kconv.rb
matz 0a64817fb8 remove marshal/gtk/kconv
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1999-08-13 05:37:52 +00:00

58 lines
907 B
Ruby

require 'nkf'
module Kconv
AUTO = NKF::AUTO
JIS = NKF::JIS
EUC = NKF::EUC
SJIS = NKF::SJIS
BINARY = NKF::BINARY
NOCONV = NKF::NOCONV
UNKNOWN = NKF::UNKNOWN
def kconv(str, out_code, in_code = AUTO)
opt = '-'
case in_code
when NKF::JIS
opt << 'J'
when NKF::EUC
opt << 'E'
when NKF::SJIS
opt << 'S'
end
case out_code
when NKF::JIS
opt << 'j'
when NKF::EUC
opt << 'e'
when NKF::SJIS
opt << 's'
when NKF::NOCONV
return str
end
opt = '' if opt == '-'
NKF::nkf(opt, str)
end
module_function :kconv
def tojis(str)
NKF::nkf('-j', str)
end
module_function :tojis
def toeuc(str)
NKF::nkf('-e', str)
end
module_function :toeuc
def tosjis(str)
NKF::nkf('-s', str)
end
module_function :tosjis
def guess(str)
NKF::guess(str)
end
module_function :guess
end