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[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