Last active
November 13, 2020 14:29
-
-
Save varvir/cd868c7aa4f15119a3f6bb19683f59ee to your computer and use it in GitHub Desktop.
MacOS utf8 encoding test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<locale> | |
#include<string> | |
using namespace std; | |
int main() | |
{ | |
locale myloc("<local machine locale or current locale>"); | |
cin.imbue(myloc); | |
cout.imbue(myloc); | |
string name; | |
cout << "이름을 입력하세요(input your name): "; | |
cin >> name; | |
cout << name << "님 안녕하세요!(hello, <name>!)" << endl; | |
cout << name.size() << "글자 이군요(your name consist of <num> letters" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
""
넣었을 때 myloc의 기본 locale이 출력되진 않았지만(걍 빈줄), MacOS도 UTF-8이 기본으로 되어있음을 알 수 있었다.size()
에서 9가 나왔다. 한 글자를 3바이트로 인식했기 때문이다.