Skip to content

Commit 1fe29a6

Browse files
committed
Handle codepoints outside the BMP
1 parent ed3fc3e commit 1fe29a6

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

engine/system/win/sys_console.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,16 @@ void sys_console_c::Print(std::u32string_view string_view_text)
298298
b+= escLen - 1;
299299
} else {
300300
// Add character
301-
*(p++) = (char16_t)text[b];
301+
if (text[b] > INT16_MAX) { // Outside the BMP
302+
char16_t high_surrogate = ((text[b] - 0x10000) >> 10) + 0xD800;
303+
char16_t low_surrogate = ((text[b] - 0x10000) << 10) + 0xDC00;
304+
*(p++) = high_surrogate;
305+
*(p++) = low_surrogate;
306+
}
307+
else {
308+
*(p++) = (char16_t)text[b];
309+
}
310+
302311
}
303312
}
304313
winText[len] = 0;

0 commit comments

Comments
 (0)