#include #include #include #include int main() { // ロケールを設定してUTF-8を使う setlocale(LC_ALL, "en_US.UTF-8"); // バイト型配列(UTF-8エンコーディング)の例 unsigned char byteData[] = { 0xE6, 0x97, 0xA5, 0xE6, 0x9C, 0xAC, 0xE8, 0xAA, 0x9E, 0x00 }; // "日本語" // バイト型配列をワイド文字列に変換 size_t numConverted; wchar_t wideStr[100]; if (mbstowcs_s(&numConverted, wideStr, sizeof(wideStr) / sizeof(wideStr[0]), (char*)byteData, _TRUNCATE) != 0) { // エラーハンドリング fprintf(stderr, "mbstowcs_s failed\n"); return 1; } // ワイド文字列を表示 wprintf(L"Wide String: %ls\n", wideStr); return 0; }