数値の末尾に付く記号を取り去る
'\0'を付け忘れていたようです。
最初は下記のようになっていた。
// Fraction.hにて // TFractionクラスのメンバ関数 System::String *ToSystemString() { std::ostrstream ostr; ostr << m_numerator << "/" << m_denominator; std::string temp = ostr.str(); ostr.freeze( false ); int nLengthForWideChar = MultiByteToWideChar( 65001/*CP_UTF8*/, 0, temp.c_str(), -1, NULL, 0 ); wchar_t *ret = new wchar_t[nLengthForWideChar]; memset( ret, 0, nLengthForWideChar * sizeof( wchar_t ) ); MultiByteToWideChar( 65001, 0, temp.c_str(), temp.size()+1, ret, nLengthForWideChar ); //MultiByteToWideChar( 65001/*CP_UTF8*/, 0, temp.c_str(), -1, ret, nLengthForWideChar ); return __gc new System::String( ret ); }
それを、下記の様に変更した。
// Fraction.hにて // TFractionクラスのメンバ関数 System::String *ToSystemString() { std::ostrstream ostr; // 最後の'\0'はMultiByteToWideCharの時に末尾ゴミをつけないため ostr << m_numerator << "/" << m_denominator << '\0'; // ←ここの最後に'\0' std::string temp = ostr.str(); ostr.freeze( false ); int nLengthForWideChar = MultiByteToWideChar( 65001/*CP_UTF8*/, 0, temp.c_str(), -1, NULL, 0 ); wchar_t *ret = new wchar_t[nLengthForWideChar]; memset( ret, 0, nLengthForWideChar * sizeof( wchar_t ) ); MultiByteToWideChar( 65001, 0, temp.c_str(), temp.size()+1, ret, nLengthForWideChar ); //MultiByteToWideChar( 65001/*CP_UTF8*/, 0, temp.c_str(), -1, ret, nLengthForWideChar ); return __gc new System::String( ret ); }
多分大丈夫だけど、色々試して確かめる必要はあるかな。