MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaO_utf8esc

Function luaO_utf8esc

src/Chain/libraries/glua/lobject.cpp:304–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302
303
304int luaO_utf8esc(char *buff, unsigned long x) {
305 int n = 1; /* number of bytes put in buffer (backwards) */
306 lua_assert(x <= 0x10FFFF);
307 if (x < 0x80) /* ascii? */
308 buff[UTF8BUFFSZ - 1] = lua_cast(char, x);
309 else { /* need continuation bytes */
310 unsigned int mfb = 0x3f; /* maximum that fits in first byte */
311 do { /* add continuation bytes */
312 buff[UTF8BUFFSZ - (n++)] = lua_cast(char, 0x80 | (x & 0x3f));
313 x >>= 6; /* remove added bits */
314 mfb >>= 1; /* now there is one less bit available in first byte */
315 } while (x > mfb); /* still needs continuation byte? */
316 buff[UTF8BUFFSZ - n] = lua_cast(char, (~mfb << 1) | x); /* add first byte */
317 }
318 return n;
319}
320
321
322/* maximum length of the conversion of a number to a string */

Callers 2

utf8escFunction · 0.85
luaO_pushvfstringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected