• 5405阅读
  • 2回复

[提问]QMultiLineEdit中输入中文,怎么获取字节数阿? [复制链接]

上一主题 下一主题
离线sunote
 

只看楼主 倒序阅读 楼主  发表于: 2008-07-16
— 本帖被 XChinux 从 Qt基础编程 移动到本区(2013-04-01) —
如题:

我的qt版本是2.3.10.

我的做法是:

const char* temp=QMltiLineEdit::text().latin();

strlen(temp);

可是返回的数据不正确。

QString 的文档上面说:

const char* QString::latin1 () const

Returns a Latin-1 representation of the string. Note that the returned value is undefined if the string contains non-Latin-1 characters. If you want to convert strings into formats other than Unicode, see the QTextCodec classes.

This function is mainly useful for boot-strapping legacy code to use Unicode.

The result remains valid so long as one unmodified copy of the source string exists
.

蓝色的部分,我看不懂!
离线longle323

只看该作者 1楼 发表于: 2008-07-16
取QString =text() 然后用.size()或者length()不能满足你的要求吗?
离线sunote

只看该作者 2楼 发表于: 2008-07-16
如果是中文呢?
QString s("中国");
这个转换成char *有几个字节呢?

我找到了答案了:
http://www.cppblog.com/cc/archive/2007/10/16/34371.html
快速回复
限100 字节
 
上一个 下一个