问题
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