2010-12-01 6 views
1
#include <iostream> 
#include <fstream> 
#include <string> 
using namespace std; 

int main() 
{ 
     locale system(""); 
     locale::global(system); 

     wcin.imbue(system); 

     wstring data; 
     getline(wcin,data); 

     wcout.imbue(system); 
     wcout << data << L" length=" << data.length() << endl; 

     locale utfFile("en_US.UTF-8"); 
     wofstream file("my_utf_file.txt"); 
     file.imbue(utfFile); 

     file << data; 
     file << endl; 

     file.close(); 

     return 0; 
} 

답변

3

귀하의 시스템입니다. 로케일 이름은 C++ 표준의 일부가 아니므로 "en_US.UTF-8"은 보편적으로 유효하지 않습니다. 그와 유사한 로케일이 존재하는지는 확실하지 않습니다.

2

파일 시스템이없는 임베디드 시스템에서는 작동하지 않습니다.

물론 해당 로켈을 설치하지 않아도됩니다.

관련 문제