Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 654107c7 authored by Martijn Coenen's avatar Martijn Coenen Committed by android-build-merger
Browse files

Merge changes from topic 'utf'

am: 213f0159

Change-Id: I12341504ac649cf8ea4558ed2ae882e3dcdce7fd
parents d7f67140 213f0159
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -765,7 +765,7 @@ status_t Parcel::writeUtf8AsUtf16(const std::string& str) {
        return NO_MEMORY;
    }

    utf8_to_utf16(strData, strLen, (char16_t*)dst);
    utf8_to_utf16(strData, strLen, (char16_t*)dst, (size_t) utf16Len + 1);

    return NO_ERROR;
}
@@ -1761,15 +1761,16 @@ status_t Parcel::readUtf8FromUtf16(std::string* str) const {
       return NO_ERROR;
    }

    ssize_t utf8Size = utf16_to_utf8_length(src, utf16Size);
    if (utf8Size < 0) {
    // Allow for closing '\0'
    ssize_t utf8Size = utf16_to_utf8_length(src, utf16Size) + 1;
    if (utf8Size < 1) {
        return BAD_VALUE;
    }
    // Note that while it is probably safe to assume string::resize keeps a
    // spare byte around for the trailing null, we're going to be explicit.
    str->resize(utf8Size + 1);
    utf16_to_utf8(src, utf16Size, &((*str)[0]));
    // spare byte around for the trailing null, we still pass the size including the trailing null
    str->resize(utf8Size);
    utf16_to_utf8(src, utf16Size, &((*str)[0]), utf8Size);
    str->resize(utf8Size - 1);
    return NO_ERROR;
}