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

Function fxUTF8Encode

xs/sources/xsCommon.c:1018–1046  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1016}
1017
1018txString fxUTF8Encode(txString string, txInteger character)
1019{
1020 txU1* p = (txU1*)string;
1021 if (character < 0) {
1022 }
1023 else if (character == 0) {
1024 *p++ = 0xC0;
1025 *p++ = 0x80;
1026 }
1027 else if (character < 0x80) {
1028 *p++ = (txU1)character;
1029 }
1030 else if (character < 0x800) {
1031 *p++ = (txU1)(0xC0 | (((txU4)character) >> 6));
1032 *p++ = (txU1)(0x80 | (((txU4)character) & 0x3F));
1033 }
1034 else if (character < 0x10000) {
1035 *p++ = (txU1)(0xE0 | (((txU4)character) >> 12));
1036 *p++ = (txU1)(0x80 | ((((txU4)character) >> 6) & 0x3F));
1037 *p++ = (txU1)(0x80 | (((txU4)character) & 0x3F));
1038 }
1039 else if (character < 0x110000) {
1040 *p++ = (txU1)(0xF0 | (((txU4)character) >> 18));
1041 *p++ = (txU1)(0x80 | ((((txU4)character) >> 12) & 0x3F));
1042 *p++ = (txU1)(0x80 | ((((txU4)character) >> 6) & 0x3F));
1043 *p++ = (txU1)(0x80 | (((txU4)character) & 0x3F));
1044 }
1045 return (txString)p;
1046}
1047
1048txSize fxUTF8Length(txInteger character)
1049{

Callers 8

JSONBase64Parser_readFunction · 0.85
xs_textencoder_encodeFunction · 0.85
xs_textdecoder_decodeFunction · 0.85
fx_printFunction · 0.85
fxWriteResultFunction · 0.85
fxEchoStringFunction · 0.85
fxCharSetStringsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected