Advertisement
phoerious

Untitled

Oct 25th, 2018
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <QTextStream>
  2.  
  3. int main()
  4. {
  5.     QTextStream out(stdout, QIODevice::WriteOnly);
  6.     QTextStream in(stdin, QIODevice::ReadOnly);
  7.  
  8.     out << "Enter unicode char: " << flush;
  9.     QString line = in.readLine();
  10.     out << "Displays correctly: " << line << ", not the correct utf-8 code: " << line.toUtf8().toHex() << endl;
  11.  
  12.     in.setCodec("UTF-8");
  13.     out.setCodec("UTF-8");
  14.     out << "\nEnter unicode char: " << flush;
  15.     line = in.readLine();
  16.     out << "Displays correctly: " << line << ", possibly the correct utf-8 code: " << line.toUtf8().toHex() << endl;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement