From 5300eecfb324f3a29d891b3e229baef631dc6aeb Mon Sep 17 00:00:00 2001 From: naruse Date: Fri, 15 Sep 2006 11:26:07 +0000 Subject: * 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 --- ext/nkf/lib/kconv.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'ext/nkf/lib') diff --git a/ext/nkf/lib/kconv.rb b/ext/nkf/lib/kconv.rb index 4ffe8d984e..91553228fe 100644 --- a/ext/nkf/lib/kconv.rb +++ b/ext/nkf/lib/kconv.rb @@ -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 str 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 self 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 # -- cgit v1.2.3