Issue on writing wstring to a file for hebrew/arabic language

和自甴很熟 提交于 2019-12-22 14:55:52

问题


I want to read hebrew(unicode) using xerces parser. I am able to read the value in XMLCh. However, while writing it to another file I get gargabe value. I tried using ofstream, wofstream but didnot helped.

Let me know your suggestions


回答1:


The problem with wofstream is that it accepts the wide string for the open() method but does not actually write wide characters to the file. You have to be explicit about that and imbue() it with a locale that has a codecvt with the encoding you want. Implementation of such a codecvt that produces a UTF encoding is still spotty, here's an example that uses Boost.




回答2:


It's been a while since I've used xerces, but I remember that XMLCh are their special character types, and probably you must convert them to wchar before writing. Alternatively you can try to save it byte by byte.. Good Luck!




回答3:


as far as i know (obout arabic) you have to write oppositely since its from right to left so write a code to switch the letters before writing it to a file



来源:https://stackoverflow.com/questions/3336690/issue-on-writing-wstring-to-a-file-for-hebrew-arabic-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!