From f1ccf0d30755b7bc91b09d017342a5dfe845e9cd Mon Sep 17 00:00:00 2001 From: Jari Bakken Date: Fri, 14 May 2010 16:22:05 +0200 Subject: [PATCH] Read correct text length back out --- lib/ffi-icu/transliteration.rb | 2 +- test.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ffi-icu/transliteration.rb b/lib/ffi-icu/transliteration.rb index 6faea76..0bb1506 100644 --- a/lib/ffi-icu/transliteration.rb +++ b/lib/ffi-icu/transliteration.rb @@ -45,7 +45,7 @@ module ICU Lib.utrans_transUChars(@tr, buf, text_length, capacity, 0, limit, error) end - buf.string + buf.string(text_length.get_int32(0)) end def close diff --git a/test.c b/test.c index 9bd7ce5..2fae878 100644 --- a/test.c +++ b/test.c @@ -23,6 +23,10 @@ int main (int argc, char const *argv[]) UErrorCode status = U_ZERO_ERROR; trans = utrans_open("Latin-Greek", UTRANS_FORWARD, NULL, 0, NULL, &status); + if(U_FAILURE(status)) { + print_error(status); + exit(1); + } UChar from[256]; UChar buf[256]; @@ -36,7 +40,7 @@ int main (int argc, char const *argv[]) printf("limit: %d\n", limit); printf("text_length: %d\n", limit); - utrans_transUChars(trans, buf, &text_length, 4, 0, &limit, &status); + utrans_transUChars(trans, buf, &text_length, 12, 0, &limit, &status); printf("uchar ptr length after: %d\n", u_strlen(buf)); printf("text_length after: %d\n", text_length);