On Wed Apr 1 11:30:45 2026 +0000, Trung Nguyen wrote:
Please also add %Z format test in swprintf test (to show that it uses ANSI_STRING). I added a case that uses `%Z` in `test_swprintf`. Please also check the function behavior with ucrtbase - current implementation will fail there. Its behavior probably changes based on \_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS or \_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY flag. I did some experiments on an `ucrt`-based toolchain: https://godbolt.org/z/sYxzWbM3x Without any legacy flag, `%Z` is always treated as wide. With `_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS`, `%Z` is treated as narrow by wide functions and wide by narrow functions. `_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY` has no effect. My previous research was done on clang/MinGW, and they probably did something weird there. Please also add tests to ucrtbase. I added tests to `test_printf_legacy_wide` to demonstrate the behavior. I checked and confirmed that it worked on Windows 11 25H2. This is not portable, please define ANSI_STRING/UNICODE_STRING structures separately and use pointers to them here. As I mentioned in the comment above, are you referring to the object literals or the structure definitions themselves? Please ignore the comment about portability - I was wrong. Sorry about that.
The results for ucrtbase are strange. The documentation states that ucrtbase has a bug that is preserved for backward compatibility. Unfortunately this means that ucrtbase needs to be special-cased. I was hoping that it can be avoided by using proper flags. I have added some minor changes to your patches: [aefe9521b1e20674f059fa52be45d45a47c44d88](https://gitlab.winehq.org/piotr/wine/-/commit/aefe9521b1e20674f059fa52be45d4...), [c84e147eceeb2a48e1053bf9e4ab7cb6ea243f9e](https://gitlab.winehq.org/piotr/wine/-/commit/c84e147eceeb2a48e1053bf9e4ab7c...). If it looks good please push the patches to this MR. Here's a short list of changes: * added more tests * fixed handling of UNICODE_STRING with broken length * pass length in characters to pf_handle_string function * simplify pf_is_str_wide helper -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10460#note_134682