QT 截取中英文字符串

dxf5457 2012-11-01 09:17:02
字符串是char类型的数组
装换成QString后长度为 中文 2,字母 1,这样截取可能会出错
请问该怎么截取
装换成wstring后截取可以么?然后我需要再次转回来该怎么转
...全文
286 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
帅得不敢出门 2012-11-02
  • 打赏
  • 举报
回复
The std::wstring is encoded in utf16 on platforms where wchar_t is 2 bytes wide (e.g. windows) and in ucs4 on platforms where wchar_t is 4 bytes wide (most Unix systems).
帅得不敢出门 2012-11-02
  • 打赏
  • 举报
回复
再转回来的话用,
QString fromUcs4 ( const uint * unicode, int size = -1 )
QString fromUtf16 ( const ushort * unicode, int size = -1 )
KyleAss 2012-11-02
  • 打赏
  • 举报
回复
没研究过,不过好像发错区了
还有,刚看一帖子“请不要将Qt写成QT”

70,037

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧