| 1042 | // ================================================================================================= |
| 1043 | |
| 1044 | static 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 | |
| 1052 | InBMP: |
| 1053 | unitCount = 1; |
| 1054 | UTF16OutSwap ( utf16Out, UTF16Unit(cpIn) ); |
| 1055 | |
| 1056 | Done: |
| 1057 | *utf16Written = unitCount; |
| 1058 | return; |
| 1059 | |
| 1060 | CheckSurrogate: |
| 1061 | if ( cpIn > 0xFFFF ) goto SurrogatePair; |
| 1062 | if ( cpIn > 0xDFFF ) goto InBMP; |
| 1063 | UC_Throw ( "Bad UTF-32 - surrogate code point", kXMPErr_BadParam ); |
| 1064 | |
| 1065 | SurrogatePair: |
| 1066 | CodePoint_to_UTF16Swp_Surrogate ( cpIn, utf16Out, utf16Len, utf16Written ); |
| 1067 | return; |
| 1068 | |
| 1069 | } // CodePoint_to_UTF16Swp |
| 1070 | |
| 1071 | // ================================================================================================= |
| 1072 |
nothing calls this directly
no test coverage detected