0

So, I've included the following:

#include <QTextCodec>

And I've also added this piece somewhere in the main function:

QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
cout << "\xE2\x88\x9E";

QTextCodec still gives me an error, saying "Cannot open source file: "QTextCodec". What I basically want to achieve is an infinity sign being printed with cout. However, I'm starting to suspect that I'm missing something big.
Help would be highly appreciated!

Max
  • 897
  • 1
  • 10
  • 27
  • 6
    `std::cout` is independent to Qt classes – Erbureth Oct 31 '13 at 13:12
  • The problem seems not to be anything related to the special character, but to an include file that cannot be found. Make sure it exists, is in a header include path, etc. – crashmstr Oct 31 '13 at 13:14
  • @Erbureth If `std::cout` is dependant on QT classes, how come including this one doesn't work? I might be a bit blind now, but I just can't see how it helps me solve the problem. – Max Oct 31 '13 at 13:24
  • @crashmstr Yeah, I figured that, but I can't seem to understand why. I'll have a look at it though, thanks. – Max Oct 31 '13 at 13:24
  • **in**-dependent. And, as @crashmstr said, problem is within the include itself. – Erbureth Oct 31 '13 at 13:34
  • @Erbureth Okay, thanks (and, quite a major difference between independant and dependant). But, I'm not quite sure of what to do... Honestly, when it comes to directives, it really isn't my strongest side, and even though I've worked with C++ for a while, I haven't really got a great catch of it. I'm using Visuals express 2012, and I cannot seem to find any specific "QTextCodec" file in the Project directory (however, I'm not sure if it's there that they're supposed to be located at). – Max Oct 31 '13 at 13:42
  • You need to download [Qt SDK](http://qt-project.org/downloads) for the include to work. However this is not the solution to your problem. Have you tried using the second line without the QTextCodec? – Erbureth Oct 31 '13 at 13:50
  • I tried removing QTextCodec, but it didn't work (also, I'll add Qt SDK). – Max Oct 31 '13 at 14:01
  • What was the output? It works just fine for me. – Erbureth Oct 31 '13 at 14:01
  • @Erbureth http://prntscr.com/20ywne - There – Max Oct 31 '13 at 14:07
  • So, yes, you have just discovered that the Windows console is not using UTF-8, see http://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how for more information – SirDarius Oct 31 '13 at 15:56

0 Answers0