Set activeCodePage to UTF-8 in the Notepad3.exe.manifest file. - #5970
Set activeCodePage to UTF-8 in the Notepad3.exe.manifest file.#5970geniuszxy wants to merge 1 commit into
Conversation
|
Hello @geniuszxy , |
|
Again, I can't reproduce your issue... 🔍 🤔
You can find this beta version here: #1129 |
|
Yes, I can reproduce this issue using the PAF version you provided. This is a video record: 2026-08-14.23-05-03.mp4 |
|
I did some research on this, and as I mentioned, it seems to be related to the version of Windows. I am using Windows 10 22H2, and the version of the kernelbase.dll is 10.0.19041.6280. I decompiled the I guess this Therefore, strings like And I downloaded another kernelbase.dll with version 10.0.26100.8972 online, the decompilation result of its From the condition of |
|
Hi @hpwamr, have you enabled "Beta: Use Unicode UTF-8 for worldwide language support" in the locale settings? This setting can solve my issue, but it can also corrupt other softwares. |
|
Thanks for putting this together, and I understand the appeal — activeCodePage=UTF-8 is generally good hygiene for modern apps. After digging into how it interacts with Notepad3 specifically, though, I don't think we should merge this. Let me explain the reasoning. What the setting actually does: UTF-8 forces the process ANSI code page to UTF-8 (65001) on Windows 10 1903+. GetACP() , CP_ACP , and CP_THREAD_ACP all resolve to UTF-8, and every -A Win32/CRT call starts treating char* as UTF-8. Notably, it does not touch the OEM code page ( GetOEMCP ). Why the upside is near-zero here: Notepad3 is already a fully Unicode application. Paths and the UI use the wide ( -W ) APIs, and Scintilla is driven explicitly with CP_UTF8 ( Encoding_SciCP ), not via CP_ACP . So the usual benefit — making legacy char* code paths UTF-8-clean — buys us almost nothing, because we don't rely on the -A APIs for the core editing/IO work. Why the downside is real and user-facing: The "ANSI (System)" encoding is a deliberate, user-visible feature, and its code page is derived from the process ACP at startup: • Encoding_InitDefaults() → CodePageFromCharSet(ANSI_CHARSET) → GetCPInfoEx(CP_THREAD_ACP, …) (fallback GetACP() ). With this manifest change, on any non-UTF-8 system (Windows-1252, Shift-JIS, GBK, etc.) the "ANSI" entry silently becomes UTF-8. Concretely:
For a text editor, the "ANSI/System" code page has to reflect the machine's real legacy locale — that's the whole point of the option, and it's what users rely on for interop with legacy files and tools. Users who want UTF-8 already have first-class UTF-8 encodings in the menu, so we'd be taking on a real behavioral regression for no practical gain. I'm happy to look at addressing that specific problem directly in a more targeted way. But as a blanket process-wide ACP override, I think we should pass on this one. Appreciate the contribution regardless! |
…with code-page-independent trim/search All prior work (analysis of rizonesoft#5970, root-cause of rizonesoft#5963, code fixes, and verified x64 build) remains complete.
Fix #5963
Referring to zufuliu#168, sometimes StrTrimA() cannot handle some UTF-8 strings correctly, so I changed the code to directly check the last two chars.I have found another way to solve this issue without touching code, referring to Use UTF-8 code pages in Windows apps, so that ANSI APIs can also handle UTF-8 strings correctly.