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.
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/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.