简体   繁体   English

从右到左隔离字符串。 C ++

[英]Right to left isolate string. C++

does anyone have experience in Unicodes? 有没有人有过Unicode的经验?

I am facing a tough problem with Farsi unicodes. 我正面临波斯unicodes的棘手问题。
I have an std::wstring s = (L"\ش\ن\ب\ه"); 我有一个std::wstring s = (L"\ش\ن\ب\ه"); which is a Farsi word. 这是波斯语。 When I debug it, I see that the underlying word is exactly what I want, but reversed. 当我调试它时,我看到底层的单词正是我想要的,但是相反。 So I have researched and found that u2067 is for right to left reading the string. 因此,我进行了研究,发现u2067是从右到左读取字符串的。
NOTE: 注意:

I cannot reverse the string manually because Farsi characters are changing their shape regardless of their position in the string. 我无法手动反转字符串,因为波斯语字符无论其在字符串中的位置如何都在改变其形状。

So I added the 2067 int the beginning and got 所以我在开始时加上了2067 int
std::wstring s = (L"\⁧\ش\ن\ب\ه"); .
But now the underlying string is the same , just added a square in the beginning if the string instead of reversing. 但是现在底层字符串是相同的,只是在字符串的开头添加了一个正方形,而不是反向。
Does anyone have experince with this stuff? 有人有经验吗? Please suggest a solution. 请提出解决方案。 Thanks! 谢谢!

The underlying string will be the same. 基础字符串将相同。 You haven't changed the order of bytes, which is written right there in the code. 您没有更改字节顺序,该顺序直接写在代码中。 But a renderer that understands Unicode should take those bytes and display the characters right-to-left. 但是可以理解Unicode的渲染器应该占用这些字节,并从右到左显示字符 That's a visual thing. 那是视觉效果。 It has nothing to do with the encoding. 它与编码无关。 From your question, it's not entirely clear what else you expected. 从您的问题来看,还不清楚您还期望什么。 It may be that you are viewing the string in a debugger, and the debugger does not support this feature of Unicode. 可能是您在调试器中查看字符串,并且调试器不支持Unicode的此功能。 If you try outputting the string to a proper console you ought to see it as you expect. 如果您尝试将字符串输出到适当的控制台,则应该按预期看到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM