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

Function CodePoint_to_UTF16Nat

xmpsdk/src/UnicodeConversions.cpp:612–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

610// =================================================================================================
611
612static void CodePoint_to_UTF16Nat ( const UTF32Unit cpIn, UTF16Unit * utf16Out, const size_t utf16Len, size_t * utf16Written )
613{
614 size_t unitCount = 0;
615
616 UC_Assert ( (utf16Out != 0) && (utf16Written != 0) );
617 if ( utf16Len == 0 ) goto Done;
618 if ( cpIn >= 0xD800 ) goto CheckSurrogate; // ! Force linear execution path for the BMP.
619
620InBMP:
621 unitCount = 1;
622 *utf16Out = UTF16Unit(cpIn);
623
624Done:
625 *utf16Written = unitCount;
626 return;
627
628CheckSurrogate:
629 if ( cpIn > 0xFFFF ) goto SurrogatePair;
630 if ( cpIn > 0xDFFF ) goto InBMP;
631 UC_Throw ( "Bad UTF-32 - surrogate code point", kXMPErr_BadParam );
632
633SurrogatePair:
634 CodePoint_to_UTF16Nat_Surrogate ( cpIn, utf16Out, utf16Len, utf16Written );
635 return;
636
637} // CodePoint_to_UTF16Nat
638
639// =================================================================================================
640

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected