0

I have problems with unicode strings. My pointer to a string in farsi (saved as Unicode, codepage 1200) return the string reversed. Why? I know that farsi is a right-to-left language, but this is a C/C++ matter. My pointer to a string should point to the start of secuence as is stored in file.

I'm using VC++2005, standard console app.

Any help will be welcomed, I have attached screenshot and sample project.

test project screen capture

Regards, Juan

JAL 1
  • 1
  • 2
    There are no codepages in Unicode. That's the whole point. – Kerrek SB Sep 13 '12 at 09:29
  • How did you type the Farsi string in your code? Did you type it right-to-left directly in the code editor, left-to-right (backwards) directly in the editor, or paste it from somewhere else? – anton.burger Sep 13 '12 at 10:39
  • Hello shambulator, I have copy/pasted the string and saved the code as "Unicode - Codepage 1200" (See Advanced Save Options under VS2005). You can check the "Test" project. Run debugger to breakpoint and see the difference between english and farsi. As consequence of this, I get printed the string in reversed order in my program. Thanks for help. – JAL 1 Sep 13 '12 at 10:50
  • Hello Shark, how can I check it? You can see the Test project if you can help me. Thanks. – JAL 1 Sep 13 '12 at 10:52

1 Answers1

0

If the order is reversed in VC++2005, then probably it just does not handle directionality right, i.e. it displays Arabic letters left to right instead of properly obeying their inherent directionality. Such things happen in many editors and development tools. It does not as such affect the behavior of applications.

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390
  • I don't agree with you, Jukka K. Korpela. Indeed, this fact is not a visual effect on the VS2005 Editor. My string is really reversed in memory. See the result of printing the string (text in the code) in the program by the same function: for(unsigned int n = 0; n – JAL 1 Sep 13 '12 at 10:56