Streaming UTF-16¶
Examples on how to work with UTF-16 streams
Stringstream¶
You can use JasonPP::u16stringstream as a stringstream for std::u16string
's.
Instead of normal char
's, it uses char16_t
's.
Otherwise just a regular ol' stringstream.
C++:¶
using namespace JasonPP;
u16stringstream ss;
ss << u"Awesome!"; // u"" is an utf-16 string literal
std::u16string myString = ss.str();
ofstream / ifstream / fstream¶
You can use JasonPP::u16fstream as a file stream for std::u16string
's.
Also features u16ofstream and u16ifstream.
Instead of normal char
's, it uses char16_t
's.
Otherwise just a regular ol' fstream.
C++:¶
using namespace JasonPP;
u16ofstream ofs;
ofs.open("myfile.txt");
// u"" is an utf-16 string literal
ofs << u"This bad boy can fit so many special characters in it:"
<< u"\u0028\u0020\u0361\u00b0\u0020\u035c\u0296\u0020\u0361\u00b0\u0029";
ofs.close();