Having problems printing åäö (├Ñ ├à | ├ñ ├ä | ├ ├û)

て烟熏妆下的殇ゞ 提交于 2021-01-28 11:16:14

问题


I can't print the swedish letters åäö.

#include <stdio.h>
#include <stdlib.h>

int main(void){
   printf("å Å | ä Ä | ö Ö");

   return 0;
}

The output I get is:

├Ñ ├à | ├ñ ├ä | ├ ├û

I don't understand what is wrong. I've searched google and stackoverflow, but nothing to be found. Maybe there is something wrong with UTF-8?

Other information that might be usefull:

I'm using Windows 10 and atom.

SOLUTION

Go to:

System language settings -> Administrative language settings -> Change system locale...

Now check the following box:

[Beta: Use Unicode UTF-8 for worldwide language support]

This fixed my problem and I am now able to use UTF-8 characters.


回答1:


The Windows command window (terminal, console, whatever you call it) does support UTF-8 since several years, at least with Windows 7 based on my experiences. You need to set the code page:

mode con cp select=65001

Additionally you can set the output code page programmatically:

SetConsoleOutputCP(CP_UTF8);


来源:https://stackoverflow.com/questions/60475759/having-problems-printing-%c3%a5%c3%a4%c3%b6-%c3%91-%c3%a0-%c3%b1-%c3%a4-%c3%82-%c3%bb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!