MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxUTF8ToUnicodeOffset

Function fxUTF8ToUnicodeOffset

xs/sources/xsCommon.c:1158–1177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1156#endif
1157
1158txSize fxUTF8ToUnicodeOffset(txString theString, txSize theOffset)
1159{
1160 txU1* p = (txU1*)theString;
1161 txU1 c;
1162 txSize unicodeOffset = 0;
1163 txSize utf8Offset = 0;
1164
1165 while ((c = c_read8(p++))) {
1166 if ((c & 0xC0) != 0x80) {
1167 if (utf8Offset == theOffset)
1168 return unicodeOffset;
1169 unicodeOffset++;
1170 }
1171 utf8Offset++;
1172 }
1173 if (utf8Offset == theOffset)
1174 return unicodeOffset;
1175 else
1176 return -1;
1177}
1178
1179#if 1
1180txSize fxUnicodeLength(txString theString, txSize* byteLength)

Callers 9

PiuCodeSearchDataFunction · 0.85
PiuCodeDrawFunction · 0.85
PiuCodeHitOffsetFunction · 0.85
PiuCodeSearchFunction · 0.85
PiuCode_findLineBreakFunction · 0.85
fx_RegExp_prototype_execFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected