vs2005에서 ifstream으로 파일명이 한글로된 파일을 읽지 못하는 문제가 생긴다.
이 때는 아래의 코드를 main에 추가해서 사용하자.
1 2 3 | #include < locale > setlocale ( LC_ALL, "Korean" ); // Console 화면에 한국어 출력 |
파일 출력이 한글로 나오지 않을 때,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include < fstream > int _tmain( int argc, _TCHAR* argv[]) { std::locale::global( std::locale( "Korean" ) ); std::wofstream fstream; fstream.open( _T( "Test1.txt" ) ); fstream << _T( "한글 파일 출력 테스트" ) << std::endl; fstream.close(); return 0; } |
덧글을 달아 주세요
namo 2008/12/14 17:18 고유주소 고치기 답하기
vs2005 이후에는 C++ standard가 적용되었으므로
#include <locale.h> 가 아닌 #include <locale> 가 되어야 할 것입니다!
TTF 2008/12/15 20:51 고유주소 고치기 답하기
namo님 지적 감사드립니다.
본문 수정하였습니다.