| 610 | // ================================================================================================= |
| 611 | |
| 612 | static 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 | |
| 620 | InBMP: |
| 621 | unitCount = 1; |
| 622 | *utf16Out = UTF16Unit(cpIn); |
| 623 | |
| 624 | Done: |
| 625 | *utf16Written = unitCount; |
| 626 | return; |
| 627 | |
| 628 | CheckSurrogate: |
| 629 | if ( cpIn > 0xFFFF ) goto SurrogatePair; |
| 630 | if ( cpIn > 0xDFFF ) goto InBMP; |
| 631 | UC_Throw ( "Bad UTF-32 - surrogate code point", kXMPErr_BadParam ); |
| 632 | |
| 633 | SurrogatePair: |
| 634 | CodePoint_to_UTF16Nat_Surrogate ( cpIn, utf16Out, utf16Len, utf16Written ); |
| 635 | return; |
| 636 | |
| 637 | } // CodePoint_to_UTF16Nat |
| 638 | |
| 639 | // ================================================================================================= |
| 640 |
nothing calls this directly
no test coverage detected