mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
2b5bb9ad00
commit
2bf3c6b631
2 changed files with 9 additions and 56 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Aug 13 08:01:59 2005 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* 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
|
||||
|
||||
Fri Aug 12 17:06:53 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (f_larglist): allow optional arguments even when
|
||||
|
|
|
@ -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 = {
|
||||
|
@ -108,46 +95,6 @@ module Kconv
|
|||
# Public Methods
|
||||
#
|
||||
|
||||
#
|
||||
# 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] )
|
||||
#
|
||||
|
@ -172,6 +119,7 @@ module Kconv
|
|||
result = ::NKF::nkf( nkf_opt, str)
|
||||
end
|
||||
module_function :conv
|
||||
alias :kconv :conv
|
||||
|
||||
#
|
||||
# Encode to
|
||||
|
|
Loading…
Reference in a new issue