文字列
String型からwstring型に変換する方法として次の方法があります。
wstring変数 = String変数->Data();
(例)
wstring_str = String_str->Data();
wstring型からString型に変換する方法として次の方法があります。
String変数 = ref new Platform::String(wstring変数.c_str());
(例)
String_str = ref new Platform::String(wstring_str.c_str());
wstring型からchar型に変換する方法として次の方法があります。
wcstombs_s(&size_t, char[], _countof(char[]), wchar_t[], _countof(char[]));
char変数 = char[];
(例)
wcstombs_s(&size_wk, char_wk, _countof(char_wk), wchar_wk, _countof(char_wk));
char_str = char_wk;
WideCharToMultiByte(CP_ACPなどの定数, WC_NO_BEST_FIT_CHARSなどの定数, wstring変数.c_str(), -1, char[], _countof(char[]), NULL, NULL);
char_str = char_wk;
(例)
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wstring_str.c_str(), -1, char_wk, _countof(char_wk), NULL, NULL);
char_str = char_wk;
char型からwstring型に変換する方法として次の方法があります。
MultiByteToWideChar(CP_ACPなどの定数, 0や必要に応じた定数, char変数, strlen(char変数) + 1, &wstring変数[0], strlen(char変数) + 1);
(例)
MultiByteToWideChar(CP_ACP, 0, char_str, strlen(char_str) + 1, &wstring_str[0], strlen(char_str) + 1);
定数 | 内容 | CP_ACP | ANSIコードページ | CP_MACCP | Macintoshコードページ | CP_OEMCP | OEMコードページ | CP_SYMBOL | シンボルコードページ(42) | CP_THREAD_ACP | 現在のスレッドのANSIコードページ | CP_UTF7 | UTF-7を使った変換 | CP_UTF8 | UTF-8を使った変換 |
wchar_t型からString型に変換する方法として次の方法があります。
const wchar_t *wchar変数 = wchar_t変数;
String変数 = ref new Platform::String(wchar変数);
(例)
const wchar_t *wchar_tmp = wchar_str;
String_str = ref new Platform::String(wchar_str);
String型からwstring型に変換する方法として次の方法があります。
wstring変数 = String変数->Data();
(例)
wstring_str = String_str->Data();
wstring型からString型に変換する方法として次の方法があります。
String変数 = ref new Platform::String(wstring変数.c_str());
(例)
String_str = ref new Platform::String(wstring_str.c_str());
wchar_t型からString型に変換する方法として次の方法があります。
const wchar_t *変数 = String変数->Data();
(例)
wchar_tmp = String_str->Data();
String型からchar型に変換する方法として次の方法があります。
wstring_str = String変数->Data();
WideCharToMultiByte(CP_ACPなどの定数, WC_NO_BEST_FIT_CHARSなどの定数, wstring変数.c_str(), -1, char[], _countof(char[]), NULL, NULL);
char変数 = cha[];
(例)
wstring_str = String_str->Data();
WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, wstring_str.c_str(), -1, char_wk, _countof(char_wk), NULL, NULL);
char_str = char_wk;
char型からString型に変換する方法として次の方法があります。
MultiByteToWideChar(CP_ACPなどの定数, 0や定数, char変数, strlen(char変数) + 1, &wstring変数[0], strlen(char変数) + 1);
String変数 = ref new Platform::String(wstring変数.c_str());
(例)
MultiByteToWideChar(CP_ACP, 0, char_str, strlen(char_str) + 1, &wstring_str[0], strlen(char_str) + 1);
String_str = ref new Platform::String(wstring_str.c_str());
続きは「進む」ボタンクリックしてください。
|
|