Skip to content

Commit f8e9aa8

Browse files
authored
Update docs/unicode.md
1 parent 8542c17 commit f8e9aa8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/unicode.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,6 +2848,9 @@ int main() {
28482848
setlocale(LC_ALL, ".utf-8"); // 设置标准库调用系统 API 所用的编码,用于 fopen,ifstream 等函数
28492849
SetConsoleOutputCP(CP_UTF8); // 设置控制台输出编码,或者写 system("chcp 65001") 也行,这里 CP_UTF8 = 65001
28502850
SetConsoleCP(CP_UTF8); // 设置控制台输入编码,用于 std::cin
2851+
#elif __APPLE__
2852+
// 通常来说 MacOS 的默认编码就是 UTF-8,这里设置全局 locale 是为了让 iswspace 接受全角空格、iswpunct 接受全角逗号 L',' 等
2853+
setlocale(LC_ALL, "UTF-8"); // MacOS 设置 UTF-8 编码,让 iswspace 接受全角空格等
28512854
#elif __unix__
28522855
// 反正 Unix 系统默认都是 UTF-8,不设置也行,这里设置全局 locale 是为了让 iswspace 接受全角空格、iswpunct 接受全角逗号 L',' 等
28532856
//setlocale(LC_ALL, "zh_CN.utf-8"); // 设置使用中文本地化,可使 strerror 输出中文(但用户必须 locale-gen 过中文!)

0 commit comments

Comments
 (0)