We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 4a2c2c5 + c538bdf commit d6e707aCopy full SHA for d6e707a
1 file changed
main.c
@@ -246,8 +246,19 @@ static uint32_t raylib_key_unshifted_codepoint(int rl_key)
246
247
// Encode a single Unicode codepoint into a UTF-8 byte buffer.
248
// Returns the number of bytes written (1–4).
249
+// Invalid codepoints (> U+10FFFF) are replaced with U+FFFD.
250
static int utf8_encode(uint32_t cp, char out[4])
251
{
252
+ // Unicode defines the maximum valid codepoint as U+10FFFF.
253
+ // Codepoints above this value are invalid and should be replaced
254
+ // with the Unicode replacement character U+FFFD.
255
+ const uint32_t MAX_UNICODE = 0x10FFFF;
256
+ const uint32_t REPLACEMENT_CHAR = 0xFFFD;
257
+
258
+ if (cp > MAX_UNICODE) {
259
+ cp = REPLACEMENT_CHAR;
260
+ }
261
262
if (cp < 0x80) {
263
out[0] = (char)cp;
264
return 1;
0 commit comments