MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / ToUTF16Native

Function ToUTF16Native

xmpsdk/src/UnicodeConversions.cpp:297–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295// =================================================================================================
296
297extern void ToUTF16Native ( const UTF8Unit * utf8In, size_t utf8Len, std::string * utf16Str )
298{
299 enum { kBufferSize = 8*1024 };
300 UTF16Unit u16Buffer[kBufferSize]; // 16K bytes
301 size_t readCount, writeCount;
302
303 utf16Str->erase();
304 utf16Str->reserve ( 2*utf8Len ); // As good a guess as any.
305
306 while ( utf8Len > 0 ) {
307 UTF8_to_UTF16Nat ( utf8In, utf8Len, u16Buffer, kBufferSize, &readCount, &writeCount );
308 if ( writeCount == 0 ) UC_Throw ( "Incomplete Unicode at end of string", kXMPErr_BadXML );
309 utf16Str->append ( (const char *)u16Buffer, writeCount*2 );
310 utf8In += readCount;
311 utf8Len -= readCount;
312 }
313
314} // ToUTF16Native
315
316// =================================================================================================
317

Callers

nothing calls this directly

Calls 3

UTF8_to_UTF16NatFunction · 0.85
reserveMethod · 0.80
eraseMethod · 0.45

Tested by

no test coverage detected