Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

fputwc(fputc)无法向stdout输出非英文 #56

Closed
mingkuang-Chuyu opened this issue Jul 27, 2019 · 2 comments
Closed

fputwc(fputc)无法向stdout输出非英文 #56

mingkuang-Chuyu opened this issue Jul 27, 2019 · 2 comments

Comments

@mingkuang-Chuyu
Copy link
Collaborator

mingkuang-Chuyu commented Jul 27, 2019

如何重现此问题?

setlocale(0, ".936");
fputwc(L'', stdout);
wprintf(L"");
std::cout << "呵呵" << std::endl;

影响范围
所有所有的VC-LTL版本均受影响,但是 4.0.2.5 Beta(包含)以后的版本影响更大。
fputwc/fputc
wprintf/printf
std::cout
等跟 stdout 输出有关操作均可能受到影响。但是普通文件流并不受此影响。

问题原因
msvcrt.dll自身缺陷,write函数不支持向stdout写入不完整的ANSI字符。

临时规避
使用 fputs,比如说 fputs("呵呵", stdout);,也可以开启 VC-LTL轻量模式,在轻量模式中 wprintf 能保证正常使用。

我们正在寻求最简单最完美的修复方案,同时欢迎大家提供解决方案。

@mingkuang-Chuyu
Copy link
Collaborator Author

mingkuang-Chuyu commented Jul 30, 2019

4.0.2.8 Beta已经修正此行为。ms vcrt历史问题。
相关修正的CRT APIs
fputwc
putwc
_fputwchar
fputc
putc
_fputchar
fwrite

@mingkuang-Chuyu
Copy link
Collaborator Author

4.0.2.9 Beta又补充对putwchar以及putchar的处理。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant