BLC 사용 예제 - 다른 문자열 타입으로 변환하기
BLC 라이브러리 다운로드
std::string을 다른 문자열 타입(std::wstring)으로 변환하는 예제 코드입니다. 모든 표준 문자열 타입간 변환이 가능하지만 이 예제에서는 std::string을 std::wstring으로만 변환합니다.
예제 코드 보기
- #include
- #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"std::string을 std::wstring으로 변환합니다."s << endl << endl;
- space.set_y(ConsoleWindow::WhereY());
-
- ConsoleWindow::ModifyStr(str, space);
- cout << endl << endl;
- cout << u8"입력받은 문자열을 제목표시줄에 출력합니다."s << endl;
- cout << u8"프로그램을 종료하려면 아무 키나 눌러주세요."s << endl << endl;
-
-
- auto wstr = ConvertString<UTF8, wstring>(str);
-
- ConsoleWindow::SetTitle(wstr);
-
- _getwch();
-
- return 0;
- }
예제 코드 접기
실행 결과
