Created
December 8, 2012 08:57
-
-
Save biac/4239366 to your computer and use it in GitHub Desktop.
MultiByteToWideChar を呼び出す Windows Phone ランタイム コンポーネント
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "pch.h" | |
#include "WindowsPhoneRuntimeComponent1.h" | |
#define CP_SJIS 932 | |
using namespace WindowsPhoneRuntimeComponent1; | |
using namespace Platform; | |
Platform::String^ WindowsPhoneRuntimeComponent::MultiByteToWideCharWP8(const Platform::Array<byte>^ buff) | |
{ | |
LPCSTR pBuff = (LPCSTR)(buff->Data); | |
const int nSize = ::MultiByteToWideChar(CP_SJIS, 0, pBuff, -1, NULL, 0); | |
BYTE* buffUtf16 = new BYTE[nSize * 2 + 2]; | |
::MultiByteToWideChar(CP_SJIS, 0, pBuff, -1, (LPWSTR)buffUtf16, nSize); | |
//return ref new Platform::String((LPWSTR)buffUtf16); | |
// ↑これではメモリリークしてしまいますね。 | |
// ということで、修正↓ (2012/12/12) | |
Platform::String^ result = ref new Platform::String((LPWSTR)buffUtf16); | |
delete[] buffUtf16; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment