Lines Matching refs:str16
122 int Utf16ToUtf8Length(const char16_t* str16, size_t str16Len)
124 if (str16 == nullptr || str16Len == 0) {
128 const char16_t* const str16End = str16 + str16Len;
130 while (str16 < str16End) {
132 if (((*str16 & 0xFC00) == 0xD800) && ((str16 + 1) < str16End)
133 && ((*(str16 + 1) & 0xFC00) == 0xDC00)) {
136 // str16 advance 2 bytes
137 str16 += 2;
139 charLen = Utf32CodePointUtf8Length(static_cast<char32_t>(*str16++));
179 // inner function and str16 is not null
180 char* Char16ToChar8(const char16_t* str16, size_t str16Len)
183 int utf8Len = Utf16ToUtf8Length(str16, str16Len);
195 StrncpyStr16ToStr8(str16, str16Len, str8, utf8Len);
199 bool String16ToString8(const u16string& str16, string& str8)
201 size_t str16Len = str16.length();
206 char* str8Temp = Char16ToChar8(str16.c_str(), str16Len);
272 UTILS_LOGE("Get str16 length failed because str8 unicode is illegal!");
282 UTILS_LOGE("Get str16 length failed because str8length is illegal!");
331 char16_t* str16 = nullptr;
334 UTILS_LOGE("Get str16 length failed,length is: %{public}d", utf16Len);
340 str16 = reinterpret_cast<char16_t*>(calloc(utf16Len, sizeof(char16_t)));
341 if (str16 == nullptr) {
346 StrncpyStr8ToStr16(str8, str8Len, str16, utf16Len);
347 return str16;
350 bool String8ToString16(const string& str8, u16string& str16)
359 UTILS_LOGD("str8 to str16 failed, str16Temp is nullptr!");
363 str16 = str16Temp;