将wstring写入希伯来语/阿拉伯语文件的问题 [英] Issue on writing wstring to a file for hebrew/arabic language

查看:300
本文介绍了将wstring写入希伯来语/阿拉伯语文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用xerces解析器阅读希伯来语(unicode)。我能够读取XMLCh中的值。然而,当它写到另一个文件,我得到gargabe值。


解决方案

div>

wofstream的问题是它接受open()方法的宽字符串,但实际上不会将宽字符写入文件。你必须是显式的和imbue()它与一个具有codecvt与你想要的编码的语言环境。实现这样一个产生UTF编码的codecvt仍然不清楚,这是一个使用Boost的示例


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

解决方案

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.

这篇关于将wstring写入希伯来语/阿拉伯语文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆