Implement the direct ByteBuffer JNI functions, GetObjectRefType, and the string region functions.
Also run tests in a consistent (alphabetical) order.
Change-Id: I1bb4f3389e749ec031254d23da349be0397c260d
diff --git a/src/utf.cc b/src/utf.cc
index 81c93ca..9356197 100644
--- a/src/utf.cc
+++ b/src/utf.cc
@@ -2,6 +2,8 @@
#include "utf.h"
+#include "logging.h"
+
namespace art {
size_t CountModifiedUtf8Chars(const char* utf8) {
@@ -31,6 +33,24 @@
}
}
+void ConvertUtf16ToModifiedUtf8(char* utf8_out, const uint16_t* utf16_in, size_t char_count) {
+ while (char_count--) {
+ uint16_t ch = *utf16_in++;
+ if (ch > 0 && ch <= 0x7f) {
+ *utf8_out++ = ch;
+ } else {
+ if (ch > 0x07ff) {
+ *utf8_out++ = (ch >> 12) | 0xe0;
+ *utf8_out++ = ((ch >> 6) & 0x3f) | 0x80;
+ *utf8_out++ = (ch & 0x3f) | 0x80;
+ } else /*(ch > 0x7f || ch == 0)*/ {
+ *utf8_out++ = (ch >> 6) | 0xc0;
+ *utf8_out++ = (ch & 0x3f) | 0x80;
+ }
+ }
+ }
+}
+
int32_t ComputeUtf16Hash(const uint16_t* chars, size_t char_count) {
int32_t hash = 0;
while (char_count--) {