mirror of
https://github.com/pocketpy/pocketpy
synced 2025-11-09 13:10:17 +00:00
Compare commits
No commits in common. "28f70cf28663be6fbb3d84087f4960048cf1f2d0" and "e0458924ae7871483e18e035c93d939845cece12" have entirely different histories.
28f70cf286
...
e0458924ae
@ -280,22 +280,10 @@ static Error* _eat_string(Lexer* self, c11_sbuf* buff, char quote, enum StringTy
|
|||||||
case 'x': {
|
case 'x': {
|
||||||
char hex[3] = {eatchar(self), eatchar(self), '\0'};
|
char hex[3] = {eatchar(self), eatchar(self), '\0'};
|
||||||
int code;
|
int code;
|
||||||
if (sscanf(hex, "%x", &code) != 1 || code > 0xFF) {
|
if(sscanf(hex, "%x", &code) != 1) {
|
||||||
return LexerError(self, "invalid hex escape");
|
return LexerError(self, "invalid hex char");
|
||||||
}
|
}
|
||||||
if (type == NORMAL_BYTES) {
|
|
||||||
// Bytes literals: write raw byte
|
|
||||||
c11_sbuf__write_char(buff, (char)code);
|
c11_sbuf__write_char(buff, (char)code);
|
||||||
} else {
|
|
||||||
// Regular strings: encode as UTF-8
|
|
||||||
if (code <= 0x7F) {
|
|
||||||
c11_sbuf__write_char(buff, (char)code);
|
|
||||||
} else {
|
|
||||||
// Encode as 2-byte UTF-8 for code points 0x80-0xFF
|
|
||||||
c11_sbuf__write_char(buff, 0xC0 | (code >> 6)); // Leading byte
|
|
||||||
c11_sbuf__write_char(buff, 0x80 | (code & 0x3F)); // Continuation byte
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
default: return LexerError(self, "invalid escape char");
|
default: return LexerError(self, "invalid escape char");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user