While debugging an issue with _vsnprintf_s() on Windows, I discovered that the behavior of %ls depends on the CRT locale, not on the Windows code page.
Consider this example:
std::string Log(const char* fmt, ...)
{
char buffer[1024];| #!/usr/bin/env node | |
| 'use strict'; | |
| /* | |
| * ftcomp_poc.js -- standalone decoder for IBM FTCOMP fT19/fT21 compression, | |
| * used inside OS/2 PACK2/FTCOMP archives. | |
| * | |
| * This is a faithful, address-literal transliteration of the decompiled | |
| * (Ghidra) C code found in: | |
| * - TKXFER.EXE.c (NE exe, "transfer" tool -- has BOTH encode (FUN_1000_902a) | |
| * and decode (FUN_1000_889a / FUN_1000_9df2 / FUN_1000_6d38) logic, and |
| // full_align_test.cpp | |
| // | |
| // Сравнивает поведение старых (non-Ex) и новых (Ex) версий функций работы | |
| // с иконками на предмет чувствительности к выравниванию входного буфера: | |
| // - CreateIconFromResource vs CreateIconFromResourceEx | |
| // - LookupIconIdFromDirectory vs LookupIconIdFromDirectoryEx | |
| // | |
| // Гипотеза: возможно, именно старые (non-Ex) версии реально требуют | |
| // DWORD-aligned буфер, а Ex-версии — просто унаследовали формулировку | |
| // в документации по инерции, хотя внутри используют более терпимый код. |
Firmware: LSW5_32_5406_SS_04_00.00.00.11-u.bin
Decompressed: LSW5_32_5406_SS_04_decompressed.bin (1,062,168 bytes)
Build date: 2025-02-06 17:00
Version string: 3.00.16 (2025-02-06 17:00 8M) (L13558)
Module: HiFlying HF-LPx70 (Bouffalo Lab BL602 SoC, RISC-V RV32IMACF)
Flash base: 0x23000000 (XIP)
Container: HF-LPx70x1 Image — 256-byte header + LZMA at offset 0x100
| deye_evse: | |
| logger: | |
| logs: | |
| custom_components.ev_smart_charger: debug | |
| template: | |
| - sensor: | |
| - name: "EV Charger Status Mapped" | |
| unique_id: ev_charger_status_mapped | |
| state: > |
| #include <windows.h> | |
| #include <string> | |
| #include <vector> | |
| /* | |
| * Returns a BCP-47 language tag (e.g. "en-US", "uk-UA", "jv-Java") | |
| * for the given HKL (keyboard layout handle). | |
| * | |
| * WM_INPUTLANGCHANGE provides HKL, whose low word is LANGID. However, | |
| * for transient keyboard layouts (LOCALE_TRANSIENT_KEYBOARD*), LANGID |
| #include <windows.h> | |
| #include <string> | |
| /* | |
| * Returns a 3-letter uppercase language abbreviation (e.g. ENG, РУС, УКР) | |
| * derived from the language autonym using winlangdb.dll. | |
| * | |
| * This matches Windows UI behavior (language indicator in taskbar): | |
| * - Uses GetLanguageNames (undocumented, WinRT language database) | |
| * - Takes the first 3 characters of the autonym |