module ICU::Lib::Util
Public Class Methods
read_null_terminated_array_of_strings(pointer)
click to toggle source
# File lib/ffi-icu/lib/util.rb, line 4 def self.read_null_terminated_array_of_strings(pointer) offset = 0 result = [] until (ptr = pointer.get_pointer(offset)).null? result << ptr.read_string offset += FFI::Pointer.size end result end
read_string_buffer(length) { |result, status| ... }
click to toggle source
# File lib/ffi-icu/lib/util.rb, line 16 def self.read_string_buffer(length) attempts = 0 begin result = FFI::MemoryPointer.new(:char, length) Lib.check_error { |status| length = yield result, status } rescue BufferOverflowError attempts += 1 retry if attempts < 2 raise BufferOverflowError, "needed: #{length}" end result.read_string(length) end
read_uchar_buffer(length) { |result, status| ... }
click to toggle source
# File lib/ffi-icu/lib/util.rb, line 31 def self.read_uchar_buffer(length) attempts = 0 begin result = UCharPointer.new(length) Lib.check_error { |status| length = yield result, status } rescue BufferOverflowError attempts += 1 retry if attempts < 2 raise BufferOverflowError, "needed: #{length}" end result.string(length) end