feat(libSceLibcInternal): implement the char16_t and char32_t codecvt conversions #21252

Closed
Herolias wants to merge 1 commit from upstream-pr/21252 into main
Herolias commented 2026-11-16 02:00:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Herolias on 2026-11-16T02:00:33Z.


What

This implements do_in and do_out of codecvt<char16_t,char,_Mbstatet> and codecvt<char32_t,char,_Mbstatet>, the UTF-8 conversions of the two facets. On main all four are sceLibcInternalPending3_0xx stubs in Err.cpp that throw. Each function is a statement-by-statement transcription of microsoft/STL 219514876e xlocale. The Dinkumware V6.00 code in crt.vc12 f1d47126bf is the same logic in an older layout. #19593 implemented the same facets' metadata and do_unshift; this PR adds the conversions on the same layout.

  • char16_t do_in (+uPwCGfmJHs) decodes UTF-8 into UTF-16:
    • Lead bytes give forms of one to six bytes. A continuation byte in lead position is stepped over and returns error, as does a bad continuation byte.
    • A value above the smaller of _Maxcode and U+10FFFF returns error.
    • A value above U+FFFF writes the high surrogate and keeps the low one in the first two bytes of the state. The last byte of the sequence is read on its own, so the pair can be split across calls.
    • If a sequence of four or more bytes for a value up to U+FFFF lacks its last byte, do_in rolls back to the start of the sequence.
    • The rollback point moves to the start of each sequence. So a truncated last sequence returns partial even after earlier sequences were converted, where the char32_t do_in returns ok.
  • char16_t do_out (0FKwlv9iH1c) encodes UTF-16 as UTF-8:
    • A high surrogate writes the lead byte and saves its bits in the state. The low surrogate then writes the other three bytes, and anything else after a high surrogate returns error.
    • The source does not check _Maxcode here, and neither does this code.
  • char32_t do_in (PJ2UDX9Tvwg) decodes forms of one to six bytes. It checks _Maxcode after the byte order mark check and keeps its state in the first byte. A sequence cut short stops the loop without a rollback.
  • char32_t do_out (eoW60zcLT8Q) checks _Maxcode before encoding and writes forms of one to six bytes.
  • Headers, both facets:
    • With _Consume_header (4), a U+FEFF as the first character is dropped. do_in then converts the rest with a virtual call through the facet's vtable at slot 0x38. If that call returns partial, the state and the input pointer are rolled back.
    • With _Generate_header (2), do_out writes EF BB BF before the first character when there is room for it and that character.
    • The char32_t do_out marks the state before it checks the room, as both source versions do. When the header does not fit it returns partial, and a later call writes no header.
  • Layout:
    • _Maxcode is the 8-byte unsigned long after the 0x10-byte facet base, at 0x10.
    • _Mode is the 4-byte enum at 0x18, the offset that CodecvtUtfMetadata.cpp on main takes from the SDK 10.00 disassembly.
    • The char16_t state is the first two bytes of _Mbstatet, and the char32_t state is its first byte. The tests check that the other bytes stay unchanged.

Reachability: neither main nor this branch exports the vtables of these facets (jlNI3SSF41o, 9H2BStEAAMg) or their ids (xM5re58mxj8, u2MAta5SS84), all of which the console's libc exports. A title that imports one of them has an unresolved data import. On Windows the relinked executable then stops at startup with FAIL: unresolved ELF import (WindowsEntryStubBuilder.cpp line 293). On Linux, LinuxElfPatcher.cpp traces only function imports (lines 253-256) and leaves data to the system loader, which I did not run. So I expect no title to reach these members through a locale yet. A facet derived in title code and used without a locale could reach them, but I know of none. None of the ten NIDs is in the title import lists of #265 to #272, though those lists leave out the NIDs that were already known to be missing. This PR claims no unblocked title. #19593 was merged under the same condition.

What still throws, and why:

  • do_length of both facets (lynApfiP6Lw and m6rjfL4aMcA). The two Dinkumware versions disagree:
    • V6.00 counts the characters that converting from a copy of the state gives (crt.vc12 xlocale lines 1267-1295 and 1534-1564).
    • microsoft/STL counts bytes and advances the caller's state (_Codecvt_do_length, lines 850-891, called from lines 1162-1165 and 1404-1407).
    • The console's do_unshift follows V6.00 where the versions differ (it returns ok, while microsoft/STL's char32_t do_unshift returns noconv). That is a hint, not proof, so do_length stays a throw until a disassembly settles it.

Debt: docs/dev/debt/changes/feat-codecvt-utf-conversions.md adds a Functional entry for the four members (757 characters), removes the four Pending entries, and changes the two do_length entries to give the reason they throw (564 characters each).

Overlap:

  • tools/pr_overlap.py --names for the six do_in, do_out and do_length names found only #17300. That PR renames libSceLibcInternal export aliases and implements none of them.
  • tools/pr_overlap.py --branch exits 2. It lists #17300 under same exports, and it cannot compare #13778, #17300, #18135, #19602 and #20059, which already conflict with main.
  • I compared each of those with git merge-tree --write-tree, against main (cf058cf14b) and against this branch:
    • #13778, #18135, #19602 and #20059 conflict in the same files, with identical conflict hunks.
    • #17300 gets two more hunks in Err.cpp (8 instead of 6). In both, #17300 renames the Pending3_017, 018 and 024 stubs that this branch deletes. Whichever PR lands second drops the renamed stubs for those NIDs and keeps the rest of the rename.
  • Six open PRs add an include to libSceLibcInternal.hpp: #13486, #13782, #19434, #19602, #19609 and #20059. Four of them append after the last line and #13782 inserts above it, so the new include goes after MultiPrecision.hpp. git merge-tree merges this branch with all six without a conflict in that header.

Not in this PR:

  • The char16_t and char32_t codecvt vtables, ids and typeinfo, which the console's libc exports. Without them these members cannot be reached through a locale.
  • do_length of both facets, pending a disassembly of the console's libc.prx.
  • ps5rs lists these four members under libc as well. Like the #19593 members, they are exported here from libSceLibcInternal only.

Tested

Fedora 44 x86-64, GCC 16.2.1, GNU ld 2.46.1, CMake 4.3.0, Ninja 1.13.2, Release with -DBUILD_TESTING=ON, on main at cf058cf14b. I ran no title, homebrew or console, because I have none. Nothing was built or run on Windows or macOS.

  • cmake --build build built the whole tree.
  • The selection from tools/select_tests.py (BUILD.md, "Selective test builds") was 5602 tests, because libSceLibcInternal is linked into almost every test. 5600 passed and 2 failed: agc_driver_image_table_packed_guards and guest_http. Both fail the same way on main at cf058cf14b, which I rebuilt and ran them on, and this branch touches neither AGC nor libSceHttp. 59 tests skipped themselves.
  • guest_codecvt_utf_conversion (new) has 22 checks. They run the exports on a facet whose vtable, _Maxcode and _Mode the test lays out itself. They check the result, both next pointers, the output and, where it changes, the state. Every call also checks that nothing is written past the end of the output and that both next pointers stay in range:
    • char16_t do_in:
      • one to three byte forms;
      • a surrogate pair from four bytes, whole and split across two calls through the state, and U+10FFFF;
      • errors: a continuation byte in lead position, a bad continuation byte, and a byte that is not a continuation while a low surrogate is pending;
      • a truncated sequence, alone and after a converted one, and empty input and output;
      • _Maxcode below U+10FFFF, and a larger one limited to U+10FFFF;
      • a five-byte form of a small value, and its rollback when the last byte is missing;
      • headers: consumed; rolled back when nothing follows; kept after the first character and without _Consume_header;
      • the retry going through slot 0x38.
    • char16_t do_out:
      • one to three byte forms and a lone low surrogate;
      • a surrogate pair as four bytes, whole and split across two calls;
      • something other than a low surrogate after a high one;
      • output that does not fit;
      • the header generated once, and nothing written when the header and the first character do not both fit.
    • char32_t do_in:
      • one to six byte forms;
      • the two lead and continuation errors;
      • a truncated sequence, alone and after a converted one;
      • _Maxcode checked after the value is read, a consumed header dropped before the check, and a kept header rejected by it;
      • headers: consumed, rolled back, and kept after the first character;
      • the retry going through slot 0x38.
    • char32_t do_out:
      • one to six byte forms;
      • _Maxcode;
      • output that does not fit;
      • the header generated;
      • partial with the state set when the header does not fit, and no header on the next call.
  • guest_codecvt_utf_metadata (the #19593 members of the same facets) and guest_libc_internal_codecvt_char pass.
  • Negative controls: I made 17 one-line changes to CodecvtUtfConversion.cpp, rebuilt the test, ran it and restored the file. Each change made it fail. They include no step over a lead continuation byte, no U+10FFFF limit, no rollback of a noncanonical sequence, the retry called directly instead of through the vtable, the retry through the do_out slot, no header rollback, the consume flag read as the generate flag, the char16_t state written as 8 bytes and the char32_t state as 4, a four-byte write for a high surrogate, unsaved surrogate bits, no header room check, five-byte forms for every lead above 0xf7, no _Maxcode check, the top bits dropped from a six-byte lead, and the header given up without marking the state. With the file restored, the test passes.
  • tools/check_conventions.py --base origin/main reports "All conventions checks passed." With --title and --body set to this title and body, it also passes.
  • tools/debt_fold.py --check passes.
  • tools/pr_overlap.py --branch feat/codecvt-utf-conversions: see Overlap above.

Sources

Behaviour Source
char16_t do_in: forms, _Maxcode limited to U+10FFFF, surrogate split through the state, noncanonical rollback, header consumed and retried through do_in, rollback on partial microsoft/STL 219514876e stl/inc/xlocale lines 965-1074; the same logic in crt.vc12 f1d47126bf src/xlocale lines 1081-1185
char16_t do_out: surrogate bits saved in the state, output counts, header generation microsoft/STL xlocale lines 1077-1150; crt.vc12 xlocale lines 1187-1255
char32_t do_in: one to six byte forms, header before _Maxcode, retry and rollback microsoft/STL xlocale lines 1264-1332; crt.vc12 xlocale lines 1405-1470
char32_t do_out: _Maxcode first, one to six byte forms, partial after marking the state when the header does not fit microsoft/STL xlocale lines 1334-1394; crt.vc12 xlocale lines 1472-1525
_Consume_header is 4 and _Generate_header is 2; _Maxcode is unsigned long followed by _Mode microsoft/STL xlocale line 894, lines 1191-1192 and 1426-1427; crt.vc12 xlocale lines 992-994, 1317-1318 and 1584-1585
_Mode at 0x18 ModeOffset in CodecvtUtfMetadata.cpp line 10, from the SDK 10.00 libc.prx disassembly recorded in the "UTF codecvt metadata and unshift" entry of docs/dev/debt/libSceLibcInternal.md line 490
The facet base is 0x10 bytes and do_in is vtable slot 0x38 GuestLocale.hpp lines 352 and 372; the codecvt<char> members call slot 0x38 the same way (docs/dev/debt/libSceLibcInternal.md line 488)
The Microsoft STL is the accepted source for libSceLibcInternal's C++ helpers docs/dev/REVERSE_ENGINEERING.md line 43
do_length differs between the two versions crt.vc12 xlocale lines 1267-1295 and 1534-1564; microsoft/STL xlocale lines 850-891, 1162-1165 and 1404-1407
The console's char32_t do_unshift returns ok, as V6.00 does (lines 1527-1532); microsoft/STL returns noconv (lines 1396-1400) docs/dev/debt/libSceLibcInternal.md line 490 (char32 unshift at 0xb31b0 in SDK 10.00 libc.prx)
The four NIDs and their names PS5 3.20 export inventory libSceLibcInternal.c lines 16396-16404; tools/nid_names.py --name gives the same NIDs for the mangled names
The console's libc exports these members, the vtables 9H2BStEAAMg and jlNI3SSF41o, and the ids u2MAta5SS84 and xM5re58mxj8 claimore22/ps5rs 2304be5131 data/stubs/by_library/libc.txt lines 35, 91, 547, 1246, 1972, 2201, 2663 and 2804

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5329724619 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21252). Originally posted by [Herolias](https://github.com/Herolias) on 2026-11-16T02:00:33Z. --- ### What This implements `do_in` and `do_out` of `codecvt<char16_t,char,_Mbstatet>` and `codecvt<char32_t,char,_Mbstatet>`, the UTF-8 conversions of the two facets. On `main` all four are `sceLibcInternalPending3_0xx` stubs in `Err.cpp` that throw. Each function is a statement-by-statement transcription of microsoft/STL 219514876e `xlocale`. The Dinkumware V6.00 code in crt.vc12 f1d47126bf is the same logic in an older layout. #19593 implemented the same facets' metadata and `do_unshift`; this PR adds the conversions on the same layout. - **`char16_t` `do_in`** (`+uPwCGfmJHs`) decodes UTF-8 into UTF-16: - Lead bytes give forms of one to six bytes. A continuation byte in lead position is stepped over and returns `error`, as does a bad continuation byte. - A value above the smaller of `_Maxcode` and U+10FFFF returns `error`. - A value above U+FFFF writes the high surrogate and keeps the low one in the first two bytes of the state. The last byte of the sequence is read on its own, so the pair can be split across calls. - If a sequence of four or more bytes for a value up to U+FFFF lacks its last byte, `do_in` rolls back to the start of the sequence. - The rollback point moves to the start of each sequence. So a truncated last sequence returns `partial` even after earlier sequences were converted, where the `char32_t` `do_in` returns `ok`. - **`char16_t` `do_out`** (`0FKwlv9iH1c`) encodes UTF-16 as UTF-8: - A high surrogate writes the lead byte and saves its bits in the state. The low surrogate then writes the other three bytes, and anything else after a high surrogate returns `error`. - The source does not check `_Maxcode` here, and neither does this code. - **`char32_t` `do_in`** (`PJ2UDX9Tvwg`) decodes forms of one to six bytes. It checks `_Maxcode` after the byte order mark check and keeps its state in the first byte. A sequence cut short stops the loop without a rollback. - **`char32_t` `do_out`** (`eoW60zcLT8Q`) checks `_Maxcode` before encoding and writes forms of one to six bytes. - **Headers, both facets:** - With `_Consume_header` (4), a U+FEFF as the first character is dropped. `do_in` then converts the rest with a virtual call through the facet's vtable at slot 0x38. If that call returns `partial`, the state and the input pointer are rolled back. - With `_Generate_header` (2), `do_out` writes EF BB BF before the first character when there is room for it and that character. - The `char32_t` `do_out` marks the state before it checks the room, as both source versions do. When the header does not fit it returns `partial`, and a later call writes no header. - **Layout:** - `_Maxcode` is the 8-byte `unsigned long` after the 0x10-byte facet base, at 0x10. - `_Mode` is the 4-byte enum at 0x18, the offset that `CodecvtUtfMetadata.cpp` on `main` takes from the SDK 10.00 disassembly. - The `char16_t` state is the first two bytes of `_Mbstatet`, and the `char32_t` state is its first byte. The tests check that the other bytes stay unchanged. Reachability: neither `main` nor this branch exports the vtables of these facets (`jlNI3SSF41o`, `9H2BStEAAMg`) or their `id`s (`xM5re58mxj8`, `u2MAta5SS84`), all of which the console's libc exports. A title that imports one of them has an unresolved data import. On Windows the relinked executable then stops at startup with `FAIL: unresolved ELF import` (`WindowsEntryStubBuilder.cpp` line 293). On Linux, `LinuxElfPatcher.cpp` traces only function imports (lines 253-256) and leaves data to the system loader, which I did not run. So I expect no title to reach these members through a locale yet. A facet derived in title code and used without a `locale` could reach them, but I know of none. None of the ten NIDs is in the title import lists of #265 to #272, though those lists leave out the NIDs that were already known to be missing. This PR claims no unblocked title. #19593 was merged under the same condition. What still throws, and why: - `do_length` of both facets (`lynApfiP6Lw` and `m6rjfL4aMcA`). The two Dinkumware versions disagree: - V6.00 counts the characters that converting from a copy of the state gives (crt.vc12 `xlocale` lines 1267-1295 and 1534-1564). - microsoft/STL counts bytes and advances the caller's state (`_Codecvt_do_length`, lines 850-891, called from lines 1162-1165 and 1404-1407). - The console's `do_unshift` follows V6.00 where the versions differ (it returns `ok`, while microsoft/STL's `char32_t` `do_unshift` returns `noconv`). That is a hint, not proof, so `do_length` stays a throw until a disassembly settles it. Debt: `docs/dev/debt/changes/feat-codecvt-utf-conversions.md` adds a Functional entry for the four members (757 characters), removes the four Pending entries, and changes the two `do_length` entries to give the reason they throw (564 characters each). Overlap: - `tools/pr_overlap.py --names` for the six `do_in`, `do_out` and `do_length` names found only #17300. That PR renames `libSceLibcInternal` export aliases and implements none of them. - `tools/pr_overlap.py --branch` exits 2. It lists #17300 under same exports, and it cannot compare #13778, #17300, #18135, #19602 and #20059, which already conflict with `main`. - I compared each of those with `git merge-tree --write-tree`, against `main` (cf058cf14b) and against this branch: - #13778, #18135, #19602 and #20059 conflict in the same files, with identical conflict hunks. - #17300 gets two more hunks in `Err.cpp` (8 instead of 6). In both, #17300 renames the `Pending3_017`, `018` and `024` stubs that this branch deletes. Whichever PR lands second drops the renamed stubs for those NIDs and keeps the rest of the rename. - Six open PRs add an include to `libSceLibcInternal.hpp`: #13486, #13782, #19434, #19602, #19609 and #20059. Four of them append after the last line and #13782 inserts above it, so the new include goes after `MultiPrecision.hpp`. `git merge-tree` merges this branch with all six without a conflict in that header. Not in this PR: - The `char16_t` and `char32_t` codecvt vtables, `id`s and typeinfo, which the console's libc exports. Without them these members cannot be reached through a locale. - `do_length` of both facets, pending a disassembly of the console's `libc.prx`. - ps5rs lists these four members under libc as well. Like the #19593 members, they are exported here from libSceLibcInternal only. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Fedora 44 x86-64, GCC 16.2.1, GNU ld 2.46.1, CMake 4.3.0, Ninja 1.13.2, Release with `-DBUILD_TESTING=ON`, on `main` at cf058cf14b. I ran no title, homebrew or console, because I have none. Nothing was built or run on Windows or macOS. - `cmake --build build` built the whole tree. - The selection from `tools/select_tests.py` (BUILD.md, "Selective test builds") was 5602 tests, because libSceLibcInternal is linked into almost every test. 5600 passed and 2 failed: `agc_driver_image_table_packed_guards` and `guest_http`. Both fail the same way on `main` at cf058cf14b, which I rebuilt and ran them on, and this branch touches neither AGC nor libSceHttp. 59 tests skipped themselves. - `guest_codecvt_utf_conversion` (new) has 22 checks. They run the exports on a facet whose vtable, `_Maxcode` and `_Mode` the test lays out itself. They check the result, both next pointers, the output and, where it changes, the state. Every call also checks that nothing is written past the end of the output and that both next pointers stay in range: - `char16_t` `do_in`: - one to three byte forms; - a surrogate pair from four bytes, whole and split across two calls through the state, and U+10FFFF; - errors: a continuation byte in lead position, a bad continuation byte, and a byte that is not a continuation while a low surrogate is pending; - a truncated sequence, alone and after a converted one, and empty input and output; - `_Maxcode` below U+10FFFF, and a larger one limited to U+10FFFF; - a five-byte form of a small value, and its rollback when the last byte is missing; - headers: consumed; rolled back when nothing follows; kept after the first character and without `_Consume_header`; - the retry going through slot 0x38. - `char16_t` `do_out`: - one to three byte forms and a lone low surrogate; - a surrogate pair as four bytes, whole and split across two calls; - something other than a low surrogate after a high one; - output that does not fit; - the header generated once, and nothing written when the header and the first character do not both fit. - `char32_t` `do_in`: - one to six byte forms; - the two lead and continuation errors; - a truncated sequence, alone and after a converted one; - `_Maxcode` checked after the value is read, a consumed header dropped before the check, and a kept header rejected by it; - headers: consumed, rolled back, and kept after the first character; - the retry going through slot 0x38. - `char32_t` `do_out`: - one to six byte forms; - `_Maxcode`; - output that does not fit; - the header generated; - `partial` with the state set when the header does not fit, and no header on the next call. - `guest_codecvt_utf_metadata` (the #19593 members of the same facets) and `guest_libc_internal_codecvt_char` pass. - Negative controls: I made 17 one-line changes to `CodecvtUtfConversion.cpp`, rebuilt the test, ran it and restored the file. Each change made it fail. They include no step over a lead continuation byte, no U+10FFFF limit, no rollback of a noncanonical sequence, the retry called directly instead of through the vtable, the retry through the `do_out` slot, no header rollback, the consume flag read as the generate flag, the `char16_t` state written as 8 bytes and the `char32_t` state as 4, a four-byte write for a high surrogate, unsaved surrogate bits, no header room check, five-byte forms for every lead above 0xf7, no `_Maxcode` check, the top bits dropped from a six-byte lead, and the header given up without marking the state. With the file restored, the test passes. - `tools/check_conventions.py --base origin/main` reports "All conventions checks passed." With `--title` and `--body` set to this title and body, it also passes. - `tools/debt_fold.py --check` passes. - `tools/pr_overlap.py --branch feat/codecvt-utf-conversions`: see Overlap above. ### Sources | Behaviour | Source | | --- | --- | | `char16_t` `do_in`: forms, `_Maxcode` limited to U+10FFFF, surrogate split through the state, noncanonical rollback, header consumed and retried through `do_in`, rollback on `partial` | [microsoft/STL 219514876e `stl/inc/xlocale` lines 965-1074](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocale#L965-L1074); the same logic in [crt.vc12 f1d47126bf `src/xlocale` lines 1081-1185](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/xlocale#L1081-L1185) | | `char16_t` `do_out`: surrogate bits saved in the state, output counts, header generation | [microsoft/STL `xlocale` lines 1077-1150](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocale#L1077-L1150); [crt.vc12 `xlocale` lines 1187-1255](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/xlocale#L1187-L1255) | | `char32_t` `do_in`: one to six byte forms, header before `_Maxcode`, retry and rollback | [microsoft/STL `xlocale` lines 1264-1332](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocale#L1264-L1332); [crt.vc12 `xlocale` lines 1405-1470](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/xlocale#L1405-L1470) | | `char32_t` `do_out`: `_Maxcode` first, one to six byte forms, `partial` after marking the state when the header does not fit | [microsoft/STL `xlocale` lines 1334-1394](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocale#L1334-L1394); [crt.vc12 `xlocale` lines 1472-1525](https://github.com/ganboing/crt.vc12/blob/f1d47126bf13d1c9dccaa6c53b72217fd0474968/src/xlocale#L1472-L1525) | | `_Consume_header` is 4 and `_Generate_header` is 2; `_Maxcode` is `unsigned long` followed by `_Mode` | [microsoft/STL `xlocale` line 894](https://github.com/microsoft/STL/blob/219514876ea86491de191ceaa88632616bbc0f19/stl/inc/xlocale#L894), lines 1191-1192 and 1426-1427; crt.vc12 `xlocale` lines 992-994, 1317-1318 and 1584-1585 | | `_Mode` at 0x18 | `ModeOffset` in [`CodecvtUtfMetadata.cpp` line 10](https://github.com/boykopovar/AnyPS5/blob/cf058cf14bcb872e29be9b34bdf8a521cec2fe00/core/libs/prx/libSceLibcInternal/CodecvtUtfMetadata.cpp#L10), from the SDK 10.00 `libc.prx` disassembly recorded in the "UTF codecvt metadata and unshift" entry of [`docs/dev/debt/libSceLibcInternal.md` line 490](https://github.com/boykopovar/AnyPS5/blob/cf058cf14bcb872e29be9b34bdf8a521cec2fe00/docs/dev/debt/libSceLibcInternal.md#L490) | | The facet base is 0x10 bytes and `do_in` is vtable slot 0x38 | [`GuestLocale.hpp` lines 352 and 372](https://github.com/boykopovar/AnyPS5/blob/cf058cf14bcb872e29be9b34bdf8a521cec2fe00/core/libs/prx/libc/include/GuestLocale.hpp#L352); the `codecvt<char>` members call slot 0x38 the same way ([`docs/dev/debt/libSceLibcInternal.md` line 488](https://github.com/boykopovar/AnyPS5/blob/cf058cf14bcb872e29be9b34bdf8a521cec2fe00/docs/dev/debt/libSceLibcInternal.md#L488)) | | The Microsoft STL is the accepted source for libSceLibcInternal's C++ helpers | [`docs/dev/REVERSE_ENGINEERING.md` line 43](https://github.com/boykopovar/AnyPS5/blob/cf058cf14bcb872e29be9b34bdf8a521cec2fe00/docs/dev/REVERSE_ENGINEERING.md#L43) | | `do_length` differs between the two versions | crt.vc12 `xlocale` lines 1267-1295 and 1534-1564; microsoft/STL `xlocale` lines 850-891, 1162-1165 and 1404-1407 | | The console's `char32_t` `do_unshift` returns `ok`, as V6.00 does (lines 1527-1532); microsoft/STL returns `noconv` (lines 1396-1400) | `docs/dev/debt/libSceLibcInternal.md` line 490 (char32 unshift at `0xb31b0` in SDK 10.00 `libc.prx`) | | The four NIDs and their names | [PS5 3.20 export inventory `libSceLibcInternal.c` lines 16396-16404](https://github.com/DNNDHH/PS5-3.20_Libs/blob/b2a77c09cd71c01f34c790cfbe98c751a13262ad/libSceLibcInternal.c#L16396-L16404); `tools/nid_names.py --name` gives the same NIDs for the mangled names | | The console's libc exports these members, the vtables `9H2BStEAAMg` and `jlNI3SSF41o`, and the `id`s `u2MAta5SS84` and `xM5re58mxj8` | [claimore22/ps5rs 2304be5131 `data/stubs/by_library/libc.txt`](https://github.com/claimore22/ps5rs/blob/2304be5131221bae0dac24b9767cabffda33f747/data/stubs/by_library/libc.txt) lines 35, 91, 547, 1246, 1972, 2201, 2663 and 2804 | ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
PrivacyOnion commented 2026-11-16 02:05:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-16T02:05:57Z.

Review: CHANGES_REQUESTED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 60dc59c251:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: guest_codecvt_utf_conversion_tests built cleanly.
  • CTest (guest_codecvt_utf_conversion):
    1/1 Test #4023: guest_codecvt_utf_conversion .....   Passed    0.02 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: the tests still pass with the change reverted, so they do not cover it

Requesting changes for the points above.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5914257189 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21252#pullrequestreview-5914257189). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-16T02:05:57Z. **Review:** CHANGES_REQUESTED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `60dc59c251`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `guest_codecvt_utf_conversion_tests` built cleanly. - **CTest** (`guest_codecvt_utf_conversion`): ``` 1/1 Test #4023: guest_codecvt_utf_conversion ..... Passed 0.02 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: the tests still pass with the change reverted, so they do not cover it Requesting changes for the points above.
MarcZX10 commented 2026-11-16 02:25:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T02:25:54Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected conversion code and tests show no verified blocking defect at head 60dc59c25146904a593994fab25a4d7b64a0edbc; execution checks were not run in this review, so a formal approval is not justified.

What I ran

Read the prepared description, commit list, manifest, and diff; inspected the full conversion implementation and the relevant test sections. No commands or tests were run. The author reports a Fedora build, tests, and negative controls; those results were not independently confirmed.

Results

Check Result Note
Source inspection passed No concrete defect found in inspected conversion paths
Build and tests not run Author-reported results only
Negative controls not run Author reports 17 one-line controls failed as intended

Findings

Blocking

None identified in the code inspected.

Non-blocking

None.

Not verified

Did not run build or tests, inspect the full test file or every changed file, or verify behavior on console hardware. Inspected CodecvtUtfConversion.cpp in full, relevant test sections, and the prepared review documents and diff. The manifest lists seven changed files, all marked included; the other changed files were not read directly. Author-reported test and negative-control results remain unverified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5914359030 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/21252#pullrequestreview-5914359030). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T02:25:54Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected conversion code and tests show no verified blocking defect at head `60dc59c25146904a593994fab25a4d7b64a0edbc`; execution checks were not run in this review, so a formal approval is not justified. ## What I ran Read the prepared description, commit list, manifest, and diff; inspected the full conversion implementation and the relevant test sections. No commands or tests were run. The author reports a Fedora build, tests, and negative controls; those results were not independently confirmed. ## Results | Check | Result | Note | | --- | --- | --- | | Source inspection | passed | No concrete defect found in inspected conversion paths | | Build and tests | not run | Author-reported results only | | Negative controls | not run | Author reports 17 one-line controls failed as intended | ## Findings ### Blocking None identified in the code inspected. ### Non-blocking None. ## Not verified Did not run build or tests, inspect the full test file or every changed file, or verify behavior on console hardware. Inspected `CodecvtUtfConversion.cpp` in full, relevant test sections, and the prepared review documents and diff. The manifest lists seven changed files, all marked included; the other changed files were not read directly. Author-reported test and negative-control results remain unverified. ## To get this to a good state Nothing is required.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!21252
No description provided.