-4

I am aiming to create an std::vector<std::string> with Farsi names. But as soon as I compile this I get this error:

enter image description here

This seems to be a unicode issue. Any suggestions how to fix this?

Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
  • 9
    thats not an error. Did you try to press `Yes` ? – 463035818_is_not_an_ai Apr 10 '18 at 14:46
  • 1
    i may sound snarky sometimes, but the intention is completely serious: As I understand this dialog it is not an error. It is asking you to save the file as Unicode to maintain your data. Of course it might be that you tried that already, but thats not apparent from your question, hence my request for clarification. Btw I tend to get upset when someone tells me to stop contributing (while stupid is something you cannot judge, so I dont really care) – 463035818_is_not_an_ai Apr 10 '18 at 14:52

1 Answers1

2

Microsoft's Visual C++ compiler does support Unicode source code files. Specifically it accepts UTF-8 (byte order mark required) or UTF-16:

Source code files

Unicode characters are now supported in identifiers, macros, string and character literals, and in comments. Universal character names are also now supported.

Unicode can be input into a source code file in the following encodings:

UTF-16 little endian with or without byte order mark (BOM)

UTF-16 big endian with or without BOM

UTF-8 with BOM

Note in particular that for UTF-8, the byte order mark is required. The dialog in your screen shot is the Visual Studio editor detecting that you have entered non-ASCII characters and asking you if you want to convert the source code file to UTF-8 or UTF-16 (not sure what the default is but I'd guess UTF-8). If you click Yes, it will save the file with a UTF-8 byte order mark (BOM) and all should be well.

TypeIA
  • 16,916
  • 1
  • 38
  • 52