ubuntu14.04中使用wxWidgets,中文无法正常显示

  最近一直在忙着把之前完成的一个wxWidgets程序从windows环境迁移到Ubuntu环境下,在迁移过程中遇到了很多奇怪的问题,有些解决了,有些还没有解决。中文是中文程序迁移到ubuntu上最核心的问题,虽然在wxWidgets文档中说了wxString是用unicode码存储数据的,使用FromUTF8 方法可以顺利的从UTF8格式的中文中读取字符,但是实际经我验证这种方法是无效的(测试环境 Ubuntu14.04  原版为英文 en_US.utf8   后来修改locale为 zh_CN.utf8).

在翻阅资料的时候我看到了这几段化。

wxString::wxString ( const std::string &  str )  

Constructs a string from str using the using the current locale encoding to convert it to Unicode (wxConvLibc).

See also
ToStdString()

std::string wxString::ToStdString (   ) const

Return the string as an std::string in current locale encoding.

Note that if the conversion of (Unicode) string contents to the current locale fails, the return string will be empty. Be sure to check for this to avoid silent data loss.

Instead of using this function it's also possible to write

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值