UTF-8 subclass of String
Return the number of UTF-8 characters.
# File UnicodeEx.rb, line 12 def length return self.unpack('U*').length end
Returns an UTF-16 String.
text = UnicodeEx::UTF8.new('Hello')
utf16 = text.to_w
# File WinEx.rb, line 262 def to_w() # Declare API calls multiByteToWideChar = Win32API.new('Kernel32','MultiByteToWideChar',['I','L','P','I','P','I'], 'I') # Get the buffer size buffer_size = multiByteToWideChar.call(WinEx::CP_UTF8, 0, self, self.bytes, nil, 0) # Reserve memory for the return string utf16_string = ' ' * buffer_size # Make the call ret = multiByteToWideChar.call(WinEx::CP_UTF8, 0, self, self.bytes, utf16_string, self.length) return utf16_string end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.