MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / _hx_utf8_char_code_at

Function _hx_utf8_char_code_at

src/String.cpp:668–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

666}
667
668int _hx_utf8_char_code_at(String inString, int inIndex)
669{
670 #ifdef HX_SMART_STRINGS
671 if (!inString.raw_ptr() || inIndex>=inString.length)
672 return 0;
673 if (inString.isUTF16Encoded())
674 return inString.raw_wptr()[inIndex];
675 else
676 return inString.raw_ptr()[inIndex];
677 #else
678 const unsigned char *src = (const unsigned char *)inString.__s;
679 const unsigned char *end = src + inString.length;
680 const unsigned char *sLen = getUtf8LenArray();
681
682 for(int i=0;i<inIndex;i++)
683 {
684 src += sLen[*src];
685 if (src==end)
686 return 0;
687 if (src>end)
688 hx::Throw(HX_CSTRING("Invalid UTF8"));
689 }
690 return DecodeAdvanceUTF8(src,end);
691 #endif
692}
693
694int _hx_utf8_length(String inString)
695{

Callers

nothing calls this directly

Calls 3

getUtf8LenArrayFunction · 0.85
ThrowFunction · 0.85
DecodeAdvanceUTF8Function · 0.85

Tested by

no test coverage detected