lib/ffi-icu/uchar.rb in ffi-icu-0.0.2 vs lib/ffi-icu/uchar.rb in ffi-icu-0.0.3
- old
+ new
@@ -6,18 +6,22 @@
def self.from_string(str)
str = str.encode("UTF-8") if str.respond_to? :encode
bytes = str.unpack("U*")
- ptr = new UCHAR_TYPE, bytes.size
+ ptr = new bytes.size
ptr.put_array_of_uint16 0, bytes
ptr
end
+ def initialize(size)
+ super UCHAR_TYPE, size
+ end
+
def resized_to(new_size)
raise "new_size must be larger than current size" if new_size < size
- resized = self.class.new UCHAR_TYPE, new_size
+ resized = self.class.new new_size
resized.put_bytes(0, get_bytes(0, size))
resized
end