mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/nkf/nkf-8/nkf.c: imported nkf 2.0.8 rev.110.
* Fix: check_bom cuts \xfe\xff\xXX\xXX of UTF-32. * Add support --ic=UTF-32. * Fix: can't guess UTF-16 and UTF-32. * Fix: can't decode beyond BMP of UTF-16LE. * ext/nkf/nkf.c (guess): Support UTF-32. * ext/nkf/lib/kconv.rb (kconv): Support UTF-32. * ext/nkf/lib/kconv.rb (to_utf32): new method. * ext/nkf/lib/kconv.rb (to_utf32): new method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
976b4e5f8b
commit
5300eecfb3
4 changed files with 131 additions and 31 deletions
|
@ -105,6 +105,8 @@ module Kconv
|
|||
opt << 'W'
|
||||
when ::NKF::UTF16
|
||||
opt << 'W16'
|
||||
when ::NKF::UTF32
|
||||
opt << 'W32'
|
||||
end
|
||||
|
||||
case out_code
|
||||
|
@ -118,6 +120,8 @@ module Kconv
|
|||
opt << 'w'
|
||||
when ::NKF::UTF16
|
||||
opt << 'w16'
|
||||
when ::NKF::UTF32
|
||||
opt << 'w32'
|
||||
when ::NKF::NOCONV
|
||||
return str
|
||||
end
|
||||
|
@ -202,6 +206,20 @@ module Kconv
|
|||
end
|
||||
module_function :toutf16
|
||||
|
||||
# call-seq:
|
||||
# Kconv.toutf32(str) -> string
|
||||
#
|
||||
# Convert <code>str</code> to UTF-32
|
||||
#
|
||||
# *Note*
|
||||
# This method decode MIME encoded string and
|
||||
# convert halfwidth katakana to fullwidth katakana.
|
||||
# If you don't want it, use NKF.nkf('-w32xm0', str).
|
||||
def toutf32(str)
|
||||
::NKF::nkf('-w32m', str)
|
||||
end
|
||||
module_function :toutf32
|
||||
|
||||
#
|
||||
# guess
|
||||
#
|
||||
|
@ -337,6 +355,17 @@ class String
|
|||
# If you don't want it, use NKF.nkf('-w16xm0', str).
|
||||
def toutf16; Kconv.toutf16(self) end
|
||||
|
||||
# call-seq:
|
||||
# String#toutf32 -> string
|
||||
#
|
||||
# Convert <code>self</code> to UTF-32
|
||||
#
|
||||
# *Note*
|
||||
# This method decode MIME encoded string and
|
||||
# convert halfwidth katakana to fullwidth katakana.
|
||||
# If you don't want it, use NKF.nkf('-w32xm0', str).
|
||||
def toutf32; Kconv.toutf32(self) end
|
||||
|
||||
#
|
||||
# is Encoding
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue