diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-12 23:19:58 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-08-12 23:19:58 +0000 |
commit | 2bf3c6b6315fa8839ff66c502ee5116711d242f1 (patch) | |
tree | 163cc97527a7b573788e3dce6e86f0ad9361253b /ext/nkf | |
parent | 2b5bb9ad00ac8205cda18a3a35e6bd906ba5223d (diff) | |
download | ruby-2bf3c6b6315fa8839ff66c502ee5116711d242f1.tar.gz |
* ext/nkf/lib/kconv.rb: Kconv.kconv is now alias of Kconv.conv
* ext/nkf/lib/kconv.rb: remove nkf dependend symbols fomr SYMBOL_TO_OPTION
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/nkf')
-rw-r--r-- | ext/nkf/lib/kconv.rb | 60 |
1 files changed, 4 insertions, 56 deletions
diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb index 2db41bf1f8..d213640028 100644 --- a/ext/nkf/lib/kconv.rb +++ b/ext/nkf/lib/kconv.rb @@ -51,6 +51,9 @@ module Kconv \xf4 [\x80-\x8f] [\x80-\xbf] [\x80-\xbf] )*\z/nx + # SYMBOL_TO_OPTION is the table for Kconv#conv + # Kconv#conv is intended to generic convertion method, + # so this table specifies symbols which can be supported not only nkf... SYMBOL_TO_OPTION = { :iso2022jp => '-j', :jis => '-j', @@ -70,25 +73,9 @@ module Kconv :utf16ben => '-w16B0', :utf16le => '-w16L', :utf16len => '-w16L0', - :noconv => '-t', :lf => '-Lu', # LF :cr => '-Lm', # CR :crlf => '-Lw', # CRLF - :fj => '--fj', # for fj - :unix => '--unix', # for unix - :mac => '--mac', # CR - :windows => '--windows', # CRLF - :mime => '--mime', # MIME encode - :base64 => '--base64', # BASE64 encode - :x0201 => '--x', # Hankaku to Zenkaku Conversion off - :nox0201 => '--X', # Hankaku to Zenkaku Conversion on - :x0212 => '--x0212', # Convert JISX0212 (Hojo Kanji) - :hiragana => '--hiragana',# Katakana to Hiragana Conversion - :katakana => '--katakana',# Hiragana to Katakana Conversion - :capinput => '--cap-input', # Convert hex after ':' - :urlinput => '--url-input', # decode percent-encoded octets - :numcharinput => '--numchar-input', # Convert Unicode Character Reference - :internalunicode => '--internal-unicode' # Use Unicode as internal encoding } CONSTANT_TO_SYMBOL = { @@ -109,46 +96,6 @@ module Kconv # # - # kconv - # - - 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' - when ::NKF::UTF8 - opt << 'W' - when ::NKF::UTF16 - opt << 'W16' - end - - case out_code - when ::NKF::JIS - opt << 'j' - when ::NKF::EUC - opt << 'e' - when ::NKF::SJIS - opt << 's' - when ::NKF::UTF8 - opt << 'w' - when ::NKF::UTF16 - opt << 'w16' - when ::NKF::NOCONV - return str - end - - opt = '' if opt == '-' - - ::NKF::nkf(opt, str) - end - module_function :kconv - - # # Kconv.conv( str, :to => :"euc-jp", :from => :shift_jis, :opt => [:hiragana, :katakana] ) # def conv(str, *args) @@ -172,6 +119,7 @@ module Kconv result = ::NKF::nkf( nkf_opt, str) end module_function :conv + alias :kconv :conv # # Encode to |