Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/libs/prx/libc/src/RuneLocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ std::uint32_t APS5_VABI towupper_nid_postfix(std::uint32_t c) {
}

std::uint32_t APS5_VABI btowc_nid_postfix(int c) {
return c == -1 ? GuestRune::Weof : static_cast<unsigned char>(c);
if (c == -1 || c < -128 || c > 255) return GuestRune::Weof;
return static_cast<unsigned char>(c);
}

int APS5_VABI wctob_nid_postfix(std::uint32_t c) {
Expand Down
2 changes: 2 additions & 0 deletions core/libs/tests/GuestRuneLocale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ int main() {
Require(towlower_nid_postfix(0xffffffff) == 0xffffffff && towupper_nid_postfix(0xffffffff) == 0xffffffff);
Require(btowc_nid_postfix(-1) == 0xffffffff && btowc_nid_postfix(0) == 0);
Require(btowc_nid_postfix('A') == 'A' && btowc_nid_postfix(0xe9) == 0xe9 && btowc_nid_postfix(-23) == 0xe9);
Require(btowc_nid_postfix(0x100) == 0xffffffff && btowc_nid_postfix(0x20ac) == 0xffffffff && btowc_nid_postfix(256) == 0xffffffff);
Require(btowc_nid_postfix(-129) == 0xffffffff && btowc_nid_postfix(-1000) == 0xffffffff);
Require(wctob_nid_postfix('A') == 'A' && wctob_nid_postfix(0xe9) == 0xe9 && wctob_nid_postfix(0) == 0);
Require(wctob_nid_postfix(0x100) == -1 && wctob_nid_postfix(0x20ac) == -1 && wctob_nid_postfix(0xffffffff) == -1);
return 0;
Expand Down
Loading