なんとな~くしあわせ?の日記

「そしてそれゆえ、知識そのものが力である」 (Nam et ipsa scientia potestas est.) 〜 フランシス・ベーコン

wxWidgetsでShift_JISからUTF-8変換

/*
 * main.cpp
 *
 *  Created on: 2012/05/15
 *      Author: learning
 */

#include <wx/wx.h>
#include <wx/strconv.h>

using namespace std;

int main() {
        // Shift_JISの文字列を const char* 型で宣言
	const char sjis[9] = {0x88,0xa2,0x82,0x70,0x90,0xb3,0x93,0x60};
        wxString sjis_wx(sjis, wxCSConv(wxT("CP932")));
	cout << sjis_wx.mb_str(wxConvUTF8) << endl;

        // 出力は「阿Q正伝」になるはず
}