From 8f2eb43b4f4ed99cdcb83698ab7af938c911a55c Mon Sep 17 00:00:00 2001 From: The Android Automerger Date: Thu, 27 Oct 2011 17:41:26 -0700 Subject: [PATCH] Revert "Fix regression in CursorWindow.copyStingToBuffer." This reverts commit d0ff68da6a606602235fb8749473999e3d1bde53. --- core/jni/android_database_CursorWindow.cpp | 2 +- include/utils/Unicode.h | 7 ------- libs/utils/Unicode.cpp | 13 ++++++------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/core/jni/android_database_CursorWindow.cpp b/core/jni/android_database_CursorWindow.cpp index 7f5c0d4f26ef8..9ff2cb2791011 100644 --- a/core/jni/android_database_CursorWindow.cpp +++ b/core/jni/android_database_CursorWindow.cpp @@ -267,7 +267,7 @@ static void fillCharArrayBufferUTF(JNIEnv* env, jobject bufferObj, if (dataObj) { if (size) { jchar* data = static_cast(env->GetPrimitiveArrayCritical(dataObj, NULL)); - utf8_to_utf16_no_null_terminator(reinterpret_cast(str), len, + utf8_to_utf16(reinterpret_cast(str), len, reinterpret_cast(data)); env->ReleasePrimitiveArrayCritical(dataObj, data, 0); } diff --git a/include/utils/Unicode.h b/include/utils/Unicode.h index 92735337705d0..6afb291f4a52e 100644 --- a/include/utils/Unicode.h +++ b/include/utils/Unicode.h @@ -149,13 +149,6 @@ void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst); */ ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen); -/** - * Convert UTF-8 to UTF-16 including surrogate pairs. - * Returns a pointer to the end of the string (where a null terminator might go - * if you wanted to add one). - */ -char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst); - /** * Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer * must be large enough to hold the result as measured by utf8_to_utf16_length diff --git a/libs/utils/Unicode.cpp b/libs/utils/Unicode.cpp index 41cbf035e5ae7..78c61b4fc632c 100644 --- a/libs/utils/Unicode.cpp +++ b/libs/utils/Unicode.cpp @@ -542,7 +542,11 @@ ssize_t utf8_to_utf16_length(const uint8_t* u8str, size_t u8len) return u16measuredLen; } -char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* u8str, size_t u8len, char16_t* u16str) +/** + * Convert a UTF-8 string to UTF-16. The destination UTF-16 buffer must have + * space for NULL at the end. + */ +void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) { const uint8_t* const u8end = u8str + u8len; const uint8_t* u8cur = u8str; @@ -565,12 +569,7 @@ char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* u8str, size_t u8len, c u8cur += u8len; } - return u16cur; -} - -void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) { - char16_t* end = utf8_to_utf16_no_null_terminator(u8str, u8len, u16str); - *end = 0; + *u16cur = 0; } }