0

I'm programming with C++ in Xcode and I am trying to print out an array, but all that it prints is "\377" and an upside down '?' at the end of it. What does this mean?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jake
  • 1
  • 1
  • BTW, octal 377 == 0xFF == 255. Do you have valid characters in your array? Are you in UTF-8 or UTF-16? – Thomas Matthews Nov 17 '14 at 17:41
  • OK, this is about ***program output***, [not compiler errors](https://stackoverflow.com/questions/12462340/377-376-appended-to-file-windows-unix) (that would be something like *"xxxx.cpp:1: error: stray ‘\377’ in program"*). I retract my close vote. – Peter Mortensen May 20 '23 at 10:35

1 Answers1

1

You probably generated whatever file you're reading on Windows in UTF-16. You should read and write your files in UTF-8. See \377\376 Appended to file (Windows -> Unix) for more details on this pretty common problem.

If you need to read files in UTF-16 in C++, see std::codecvt. That will help you get it over to UTF-8, which is what most of the Mac libraries expect.

Community
  • 1
  • 1
Rob Napier
  • 286,113
  • 34
  • 456
  • 610