QString和德语的小写字母
QString and german umlauts
我正在用c++和QT工作,并有一个问题与德国变音符。我有一个像"wir sind m
我试着这样做:
s = s.replace( QChar('ü'), QString("ü"));
但它不工作。
也
s = s.replace( QChar('u00fc'), QString("ü"))
不工作
当我在循环中遍历字符串的所有字符时,'ü'是两个字符。
有人能帮我吗?qstring为UTF-16。
QString存储一个16位QChar字符串,其中每个QChar对应一个Unicode 4.0字符。(码值大于65535的Unicode字符使用代理字符对存储,即两个连续的qchar。)
所以尝试
//if ü is utf-16, see your fileencoding to know this
s.replace("ü", "ü")
//if ü if you are inputting it from an editor in latin1 mode
s.replace(QString::fromLatin1("ü"), "ü");
s.replace(QString::fromUtf8("ü"), "ü"); //there are a bunch of others, just make sure to select the correct one
ü
在Unicode中有两种不同的表示:
- 单点
00FC
(拉丁小写字母U WITH DIAERESIS) - 序列
0075
(拉丁小写字母U)0308
(combined DIAERESIS)
相关文章:
- 比较并显示使用最小值(a,b)和最大值(a、b)升序排列的4个数字
- 最小硬币更换问题(自上而下方法)
- Qt VTK交互风格的信号到小部件
- 芬威克树(BIT).找到具有给定累积频率的最小索引,单位为 O(logN)
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 使用递归的数组的最小值.这是怎么回事
- 为什么在浮点中从大到小会引入更多的误差
- 找到两对数字,使它们的乘积的绝对差最小化
- 如何使用boost::具有嵌套结构和最小代码更改的序列化
- 最大和最小 1 C++函数
- 如何创建一个函数来计算并返回平均值、最大值和最小值
- 我可以做些什么来消除或最小化这种将提供相同功能和行为的代码重复
- 如何在QT中的自定义视频小工具t上绘制矩形
- 在二维数组中查找最小值和最大值?
- 查找矩阵C++中每一列和每一行的最小和最大元素
- 如何找到大于整数的最小数字
- 小字符串优化(调试与发布模式)
- QtDesigner自定义小部件
- 字节真的是最小可寻址单元吗
- 带自定义比较器的最小优先级队列