X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fruby.git;a=blobdiff_plain;f=chise%2Ficonv.rb;h=d361da685cccb987fb75eb510e161e4dd677d0d6;hp=5ef044ba7d1e32c58876cc3f8f5ce6b3327ca365;hb=532444ed9ee69c56b57e0958769b76dc149ebcd2;hpb=3bb61fc3d9acdb9565d6a8e2f1b23bfa2342490d diff --git a/chise/iconv.rb b/chise/iconv.rb index 5ef044b..d361da6 100755 --- a/chise/iconv.rb +++ b/chise/iconv.rb @@ -77,10 +77,35 @@ class String def u16toeuc() Iconv.iconv_to_from("EUC-JP", "UTF-16", self) end def u16tosjis() Iconv.iconv_to_from("Shift_JIS", "UTF-16", self) end - def u32to_i - return 0 if length == 0 - s = self -# return (s[3] << 24 | s[2] << 16 | s[1] << 8 | s[0]) - return (s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]) - end +# def u32to_i +# return 0 if length == 0 +# s = self +# return (s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]) +# end + +# def u8to_i +# u32 = self.u8tou32 +# u32.u32to_i +# end +end + +module CHISE +# def i_tou32(n) # convert a integer to UTF-32 String +# raise unless n.is_a?(Integer) +# sprintf("%c%c%c%c", (n >> 24)&0xff, (n >> 16)&0xff, (n >> 8)&0xff, n&0xff) +# end + +# def i_tou8(n) # convert a integer to UTF-8 String +# u32 = CHISE.i_tou32(n) +# u32.u32tou8 +# end +# module_function :i_tou32, :i_tou8 +end + +class NuUconv + def self.u8tou4(s) s.u8tou32; end + def self.u4tou8(s) s.u32tou8; end + def self.u4tou16(s) s.u32tou16; end + def self.u16toeuc(s) s.u16toeuc; end + def self.u16tosjis(s) s.u16tosjis; end end