프로그래밍

[C/C++] 파일 입출력 std::wfstream UTF-8 파일 읽기

Mesia 2015. 7. 5. 17:58

#include <locale>

#include <fstream>

 

void main(int argc, wchar_t* argv)

{

wstring buff;

wfstream fs("utf8_file.txt");

 

std::locale::global(std::locale("ko_KR.UTF-8")); // 맨 처음 한번 실행

 

while ( getline(fs, buff) ) { // 파일을 처음부터 끝까지 한줄씩 (마지막 \n 은 자동으로 제거됨) 읽음.

do_something();

}

 

참고자료: http://trowind.tistory.com/61