No, std::u32string is (as the name implies) UTF32 and not UTF8. UTF32 has it's own uses but I don't think you don't really need it.
By UTF8 string I mean just a regular char array/std::string that uses UTF8 encoding. Here's an example of what concatenating 2 UTF8 strings would look like:
Code: Select all
std::string utf8_str1 = GetSomeUtf8String();
std::string utf8_str2 = GetAnotherUtf8String();
std::string concatenated = utf8_str1 + utf8_str2;
Here's an example of what finding a UTF8 substring looks like:
Code: Select all
std::string utf8_str1 = GetSomeUtf8String();
std::string utf8_str2 = GetAnotherUtf8String();
size_t found = utf8_str1.find(utf8_str2);
if (found != string::npos)
// Found
Here's an example for looking through a string for an ASCII character:
Code: Select all
std::string utf8_str = GetSomeUtf8String();
for( size_t i = 0; i < utf8_str.size(); i++ )
{
if( utf8_str[i] == '9' )
{
// Found the character '9'
}
}
And finally here's an example of passing a UTF8 encoded string into a function that expects an ASCII encoded string:
Code: Select all
void DoSomethingWithAsciiStr( const char* ascii_str );
std::string utf8_str = GetSomeUtf8String();
DoSomethingWithAsciiStr( utf8_str.c_str() );
Notice how everything above works exactly as it would if you had a normal ASCII encoded string. UTF8 encoding was specifically designed in this way so the above stuff "just works".