Skip to content

Commit 8f2eb43

Browse files
author
The Android Automerger
committed
Revert "Fix regression in CursorWindow.copyStingToBuffer."
This reverts commit d0ff68d.
1 parent 095b098 commit 8f2eb43

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

core/jni/android_database_CursorWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static void fillCharArrayBufferUTF(JNIEnv* env, jobject bufferObj,
267267
if (dataObj) {
268268
if (size) {
269269
jchar* data = static_cast<jchar*>(env->GetPrimitiveArrayCritical(dataObj, NULL));
270-
utf8_to_utf16_no_null_terminator(reinterpret_cast<const uint8_t*>(str), len,
270+
utf8_to_utf16(reinterpret_cast<const uint8_t*>(str), len,
271271
reinterpret_cast<char16_t*>(data));
272272
env->ReleasePrimitiveArrayCritical(dataObj, data, 0);
273273
}

include/utils/Unicode.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,6 @@ void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst);
149149
*/
150150
ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen);
151151

152-
/**
153-
* Convert UTF-8 to UTF-16 including surrogate pairs.
154-
* Returns a pointer to the end of the string (where a null terminator might go
155-
* if you wanted to add one).
156-
*/
157-
char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst);
158-
159152
/**
160153
* Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer
161154
* must be large enough to hold the result as measured by utf8_to_utf16_length

libs/utils/Unicode.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,11 @@ ssize_t utf8_to_utf16_length(const uint8_t* u8str, size_t u8len)
542542
return u16measuredLen;
543543
}
544544

545-
char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* u8str, size_t u8len, char16_t* u16str)
545+
/**
546+
* Convert a UTF-8 string to UTF-16. The destination UTF-16 buffer must have
547+
* space for NULL at the end.
548+
*/
549+
void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str)
546550
{
547551
const uint8_t* const u8end = u8str + u8len;
548552
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
565569

566570
u8cur += u8len;
567571
}
568-
return u16cur;
569-
}
570-
571-
void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) {
572-
char16_t* end = utf8_to_utf16_no_null_terminator(u8str, u8len, u16str);
573-
*end = 0;
572+
*u16cur = 0;
574573
}
575574

576575
}

0 commit comments

Comments
 (0)