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

Function FromUTF16Native

xmpsdk/src/UnicodeConversions.cpp:387–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385// =================================================================================================
386
387extern void FromUTF16Native ( const UTF16Unit * utf16In, size_t utf16Len, std::string * utf8Str )
388{
389 enum { kBufferSize = 16*1024 };
390 UTF8Unit u8Buffer[kBufferSize];
391 size_t readCount, writeCount;
392
393 utf8Str->erase();
394 utf8Str->reserve ( 2*utf16Len ); // As good a guess as any.
395
396 while ( utf16Len > 0 ) {
397 UTF16Nat_to_UTF8 ( utf16In, utf16Len, u8Buffer, kBufferSize, &readCount, &writeCount );
398 if ( writeCount == 0 ) UC_Throw ( "Incomplete Unicode at end of string", kXMPErr_BadXML );
399 utf8Str->append ( (const char *)u8Buffer, writeCount );
400 utf16In += readCount;
401 utf16Len -= readCount;
402 }
403
404} // FromUTF16Native
405
406// =================================================================================================
407

Callers

nothing calls this directly

Calls 3

UTF16Nat_to_UTF8Function · 0.85
reserveMethod · 0.80
eraseMethod · 0.45

Tested by

no test coverage detected