Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C++

Idiom #24 Assign to string the japanese word ネコ

Declare a new string s and initialize it with the literal value "ネコ" (which means "cat" in japanese)

#include <string>
std::string s = u8"ネコ";

This creates a UTF-8 string object. You can use other string types (wide string, UTF-16, UTF-32) by using different types and literal prefixes.
const char * s = "ネコ";

C has no notion of character sets, output depends on locale settings and terminal capabilities.

New implementation...