BLC 사용 예제 - 인코딩 변환기
BLC 라이브러리 다운로드
UTF-8 인코딩의 문자열을 CP949 인코딩의 문자열로 변환하는 예제 코드입니다.
예제 코드 보기
- #include
- #include
- #include
-
- #include
- #include
-
- int main()
- {
- using namespace blc::console;
- using namespace blc::ustr;
- using namespace blc::ustr::encoding;
- using namespace std;
-
- SetCharacterWidthFunc(mk_wcwidth_cjk);
-
-
- ConsoleWindow::SetTitle(L"인코딩 변환기 예제"s);
-
- auto str = u8""s;
- ConsoleWindow::Space space(0, 0, 60, 1);
-
- cout << u8"입력한 문자열(UTF-8)을 CP949 인코딩으로 변환합니다."s << endl << endl;
- space.set_y(ConsoleWindow::WhereY());
-
- ConsoleWindow::ModifyStr(str, space);
- cout << endl << endl;
-
- auto utf8 = ConvertString<UTF8, string>(str);
- auto cp949 = ConvertEncoding<CP949, UTF8>(utf8, false);
-
-
-
-
-
- cout << u8"UTF-8 출력모드에서 CP949 출력 시도"s << endl;
- cout << cp949 << endl << endl;
-
- cout << u8"출력 모드를 CP949 로 변환하여 출력 시도"s << endl;
- {
-
- ConsoleOutputCP cp949_output_mode(ConsoleOutputCP::kCP949_);
-
- cout << cp949 << endl << endl;
- }
-
- return 0;
- }
예제 코드 접기
실행 결과
