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

Function CodePoint_to_UTF16Swp

xmpsdk/src/UnicodeConversions.cpp:1044–1069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1042// =================================================================================================
1043
1044static void CodePoint_to_UTF16Swp ( const UTF32Unit cpIn, UTF16Unit * utf16Out, const size_t utf16Len, size_t * utf16Written )
1045{
1046 size_t unitCount = 0;
1047
1048 UC_Assert ( (utf16Out != 0) && (utf16Written != 0) );
1049 if ( utf16Len == 0 ) goto Done;
1050 if ( cpIn >= 0xD800 ) goto CheckSurrogate; // ! Force linear execution path for the BMP.
1051
1052InBMP:
1053 unitCount = 1;
1054 UTF16OutSwap ( utf16Out, UTF16Unit(cpIn) );
1055
1056Done:
1057 *utf16Written = unitCount;
1058 return;
1059
1060CheckSurrogate:
1061 if ( cpIn > 0xFFFF ) goto SurrogatePair;
1062 if ( cpIn > 0xDFFF ) goto InBMP;
1063 UC_Throw ( "Bad UTF-32 - surrogate code point", kXMPErr_BadParam );
1064
1065SurrogatePair:
1066 CodePoint_to_UTF16Swp_Surrogate ( cpIn, utf16Out, utf16Len, utf16Written );
1067 return;
1068
1069} // CodePoint_to_UTF16Swp
1070
1071// =================================================================================================
1072

Callers

nothing calls this directly

Calls 2

UTF16OutSwapFunction · 0.85

Tested by

no test coverage detected