// each of which has a 4-byte UTF-8 encoding.
inline std::string MakeLongUTF8String(size_t num_4_byte_chars) {
// An example of a longest valid UTF-8 character.
- const std::string earth_africa("\xF0\x9F\x8C\x8D");
+ // Be explicit about the character type becuase Microsoft compilers can
+ // otherwise interpret the character string as being over wide (16-bit)
+ // characters. Ideally, we would just use a C++11 UTF-8 string literal,
+ // but we want to support older Microsoft compilers.
+ const std::basic_string<char> earth_africa("\xF0\x9F\x8C\x8D");
EXPECT_EQ(4, earth_africa.size());
+
std::string result;
result.reserve(num_4_byte_chars * 4);
for (size_t i = 0; i < num_4_byte_chars; i++ ) {