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

Function FromUTF32

xmpsdk/src/UnicodeConversions.cpp:408–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406// =================================================================================================
407
408extern void FromUTF32 ( const UTF32Unit * utf32In, size_t utf32Len, std::string * utf8Str, bool bigEndian )
409{
410 UTF32_to_UTF8_Proc Converter = UTF32LE_to_UTF8;
411 if ( bigEndian ) Converter = UTF32BE_to_UTF8;
412
413 enum { kBufferSize = 16*1024 };
414 UTF8Unit u8Buffer[kBufferSize];
415 size_t readCount, writeCount;
416
417 utf8Str->erase();
418 utf8Str->reserve ( 2*utf32Len ); // As good a guess as any.
419
420 while ( utf32Len > 0 ) {
421 Converter ( utf32In, utf32Len, u8Buffer, kBufferSize, &readCount, &writeCount );
422 if ( writeCount == 0 ) UC_Throw ( "Incomplete Unicode at end of string", kXMPErr_BadXML );
423 utf8Str->append ( (const char *)u8Buffer, writeCount );
424 utf32In += readCount;
425 utf32Len -= readCount;
426 }
427
428} // FromUTF32
429
430// =================================================================================================
431

Callers

nothing calls this directly

Calls 3

ConverterClass · 0.85
reserveMethod · 0.80
eraseMethod · 0.45

Tested by

no test coverage detected