MCPcopy Create free account
hub / github.com/axmolengine/axmol / ConvertUTF8toUTF32Impl

Function ConvertUTF8toUTF32Impl

3rdparty/ConvertUTF/ConvertUTF.cpp:641–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

639/* --------------------------------------------------------------------- */
640
641static ConversionResult ConvertUTF8toUTF32Impl(
642 const UTF8** sourceStart, const UTF8* sourceEnd,
643 UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags,
644 Boolean InputIsPartial) {
645 ConversionResult result = conversionOK;
646 const UTF8* source = *sourceStart;
647 UTF32* target = *targetStart;
648 while (source < sourceEnd) {
649 UTF32 ch = 0;
650 unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
651 if (extraBytesToRead >= sourceEnd - source) {
652 if (flags == strictConversion || InputIsPartial) {
653 result = sourceExhausted;
654 break;
655 } else {
656 result = sourceIllegal;
657
658 /*
659 * Replace the maximal subpart of ill-formed sequence with
660 * replacement character.
661 */
662 source += findMaximalSubpartOfIllFormedUTF8Sequence(source,
663 sourceEnd);
664 *target++ = UNI_REPLACEMENT_CHAR;
665 continue;
666 }
667 }
668 if (target >= targetEnd) {
669 result = targetExhausted; break;
670 }
671
672 /* Do this check whether lenient or strict */
673 if (!isLegalUTF8(source, extraBytesToRead+1)) {
674 result = sourceIllegal;
675 if (flags == strictConversion) {
676 /* Abort conversion. */
677 break;
678 } else {
679 /*
680 * Replace the maximal subpart of ill-formed sequence with
681 * replacement character.
682 */
683 source += findMaximalSubpartOfIllFormedUTF8Sequence(source,
684 sourceEnd);
685 *target++ = UNI_REPLACEMENT_CHAR;
686 continue;
687 }
688 }
689 /*
690 * The cases all fall through. See "Note A" below.
691 */
692 switch (extraBytesToRead) {
693 case 5: ch += *source++; ch <<= 6;
694 case 4: ch += *source++; ch <<= 6;
695 case 3: ch += *source++; ch <<= 6;
696 case 2: ch += *source++; ch <<= 6;
697 case 1: ch += *source++; ch <<= 6;
698 case 0: ch += *source++;

Callers 2

ConvertUTF8toUTF32Function · 0.85

Calls 2

isLegalUTF8Function · 0.85

Tested by

no test coverage detected