Got collation working, though it's super slow

This commit is contained in:
Jari Bakken 2010-05-11 00:03:44 +02:00
parent 8556bc7be4
commit 5ff5d67801
2 changed files with 8 additions and 18 deletions

View File

@ -39,8 +39,8 @@ module ICU
array.sort do |a,b|
Lib.ucol_strcoll(
@c,
UCharPointer.from_string(a), a.length,
UCharPointer.from_string(b), b.length
UCharPointer.from_string(a), a.size,
UCharPointer.from_string(b), b.size
)
end
end

View File

@ -1,21 +1,11 @@
require 'iconv'
module ICU
class UCharPointer < FFI::MemoryPointer
def self.from_string(str)
bytes = str.bytes.to_a
ptr = new(:uint16, bytes.size)
ptr.put_array_of_uint16(0, bytes)
ptr
super Iconv.conv("wchar_t", "utf-8", str.encode("UTF-8"))
end
end
# class UCharIteratorPointer < FFI::MemoryPointer
# def self.from_string(str)
# ptr = new(:pointer, 4)
# Lib.uiter_setUTF8(ptr, str, str.length)
# ptr
# end
# end
end
end