문제

I'm new in c++ and have problem with converting UnicodeString to string, so now searching for easiest method to convert from one type to other.

I want to use basic windows function which needs string with UnicodeString, how to make code work?

UnicodeString Exec = "notepad";
WinExec(Exec.c_str(), 0);

Environment used is c++ builder xe2

도움이 되었습니까?

해결책

A std::string can not store unicode data. You will need a std::wstring for that.

I've never heard of UnicodeString before, but looking at the API here:

http://docwiki.embarcadero.com/Libraries/XE2/en/System.UnicodeString_Methods

It has a function called .c_str() which returns a wchar_t* which you can then use to construct a std::wstring

If you really need a std::string, then have a look at this answer.

How to convert wstring into string?

다른 팁

If you are looking for complete unicode support in C++ go for ICU API. Here is the website where you can find everything about it. http://site.icu-project.org/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top