Created
August 18, 2016 00:50
-
-
Save SeanCline/a039ea5d02901a730a76d94facce86e1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#pragma once | |
#include <string> | |
#include <codecvt> | |
Platform::String^ to_PlatformString(const char* from) | |
{ | |
std::wstring_convert<std::codecvt<wchar_t, char, mbstate_t>> convert; | |
auto wide = convert.from_bytes(from); | |
return ref new Platform::String(wide.c_str(), static_cast<unsigned int>(wide.size())); | |
} | |
Platform::String^ to_PlatformString(const wchar_t* from) | |
{ | |
return ref new Platform::String(from); | |
} | |
Platform::String^ to_PlatformString(const std::string& from) | |
{ | |
std::wstring_convert<std::codecvt<wchar_t, char, mbstate_t>> convert; | |
auto wide = convert.from_bytes(from); | |
return ref new Platform::String(wide.c_str(), static_cast<unsigned int>(wide.size())); | |
} | |
Platform::String^ to_PlatformString(const std::wstring& from) | |
{ | |
return ref new Platform::String(from.c_str(), static_cast<unsigned int>(from.size())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment