I think what wiliml meant was that in C++11 you can write UTF8 encoded strings as u8"I'm a UTF-8 string." This is done at compile time so it will not help you if you want to encode the strings at runtime.
If you want to convert the string to UTF8 (at runtime) you first have to know what encoding the original string is using.
For the purpose of enhancing support for Unicode in C++ compilers, the definition of the type char has been modified to be both at least the size necessary to store an eight-bit coding of UTF-8 and large enough to contain any member of the compiler's basic execution character set. It was previously defined as only the latter.
And:
Wikipedia wrote:
1 2 3
u8"I'm a UTF-8 string."
u"This is a UTF-16 string."
U"This is a UTF-32 string."
The type of the first string is the usual const char[]. The type of the second string is const char16_t[]. The type of the third string is const char32_t[].
As you see, the regular type char has UTF8 encoding
char test[10] = "Hellóóóó";
//Here encode test in utf8
On the majority of platforms, it is already in UTF-8, see ideone.com's linux for example: http://ideone.com/iSKK2
In other cases, there are plenty of platform-specific means to do that conversion, or, in C++11, standard means as well. But, as already pointed out, adding a u8 before the opening " enforces that on all platforms/environments, if you have C++11 support.
If you don't, then try to give as much detail as possible about your platform and compiler.