diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-24 04:31:29 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-24 04:31:29 +0000 |
commit | 831aa6cd961ce56ef248d3a078db4f75c5d2bf6b (patch) | |
tree | cb461ab9246a2c8e13d373a8c2d2e6378e4db9cc /ext/nkf/lib/kconv.rb | |
parent | 62e648e148b3cb9f96dcce808c55c02b7ccb4486 (diff) |
This commit was manufactured by cvs2svn to create tag
'v1_3_1_990224'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_3_1_990224@406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/nkf/lib/kconv.rb')
-rw-r--r-- | ext/nkf/lib/kconv.rb | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb new file mode 100644 index 0000000000..bfd276330d --- /dev/null +++ b/ext/nkf/lib/kconv.rb @@ -0,0 +1,58 @@ +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 |