C++/Library
2021. 3. 26. 15:28
wstring
<string>
라이브러리일반적인
char
의 범위를 넘어가는 유니코드 등의 글자를 저장할 때 사용되는 클래스이다.#include <iostream> #include <locale> #include <cstddef> int main() { using namespace std; const wstring texts[] = { L"Hello", // English L"안녕하세요", // Korean L"Ñá", // Spanish L"forêt intérêt", // French L"Gesäß", // German L"取消波蘇日奇諾", // Chinese L"日本人のビット", // Japanese L"немного русский", // Russian L"ένα κομμάτι της ελληνικής", // Greek L"ਯੂਨਾਨੀ ਦੀ ਇੱਕ ਬਿੱਟ", // Punjabi (wtf?). xD L"کمی از ایران ", // Persian (I know it, from 300 movie) L"కానీ ఈ ఏమి నరకం ఉంది?", //Telugu (telu-what?) L"Но какво, по дяволите, е това?" //Bulgarian }; std::locale::global(std::locale("")); std::wcout.imbue(std::locale()); for (size_t i = 0; i < 13; ++i) wcout << texts[i] << endl; } /* stdout stderr Hello 안녕하세요 Na foret interet Gesaß 取消波蘇日奇諾 日本人のビット немного русский */
처음엔
Hello
밖에 출력되지 않아서,제어판 - 지역(Region)
에 들어가서Administrative
탭의Language for non-Unicode programs
를 한국어로 변경했다.이외의 외국어가 출력되지 않는 이유는 아마 언어팩이 설치되어있지 않아서 그런 것 같다.
'C++ > Library' 카테고리의 다른 글
C++ ostream (0) | 2021.03.29 |
---|---|
C++ istream (0) | 2021.03.29 |
C++ sstream (0) | 2021.03.26 |
C++ string (0) | 2021.03.26 |
C++ STL 알고리즘 (Algorithms) (0) | 2021.03.26 |