Fix GetUtfLength to add offset to char array data.
GetUtfLength isn't used by much, so I made ToModifiedUtf8 use it so it
can be exercised more. Also added a test to make sure it's working.
Change-Id: I9d569642aaf2313cc70a2e22f631aec138e2e71b
diff --git a/src/object.cc b/src/object.cc
index 207a175..ad0f6b9 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -1469,7 +1469,7 @@
// Create a modified UTF-8 encoded std::string from a java/lang/String object.
std::string String::ToModifiedUtf8() const {
const uint16_t* chars = GetCharArray()->GetData() + GetOffset();
- size_t byte_count(CountUtf8Bytes(chars, GetLength()));
+ size_t byte_count = GetUtfLength();
std::string result(byte_count, static_cast<char>(0));
ConvertUtf16ToModifiedUtf8(&result[0], chars, GetLength());
return result;