关于字符串编码,C++语言,计算“abc的”这个字符串的长度,Linux为6,Windows为5。如何让Windows长度也6

[复制链接]
查看11 | 回复4 | 2013-4-10 08:35:38 | 显示全部楼层 |阅读模式
stringA type that describes a specialization of the template class basic_string with elements of type char as a string.wstringA type that describes a specialization of the template class basic_string with elements of type wchar_t as a wstring.int main(){wstring strTest ( L"中文" );cout << "size:" << strTest.size() <<...
回复

使用道具 举报

千问 | 2013-4-10 08:35:38 | 显示全部楼层
不能设置,修改编码种类到UTF可以让一个字符的长度为2汉字占两个字节,再加‘\0’就3个字节...
回复

使用道具 举报

千问 | 2013-4-10 08:35:38 | 显示全部楼层
vc程序的字符集只有两种ansi和unicode。文本存储的时候可以是ansi,unicode,utf8等,你可以在读取的时候只能判断是什么编码,然后转换为你在程序中使用的编码,然后计算。...
回复

使用道具 举报

千问 | 2013-4-10 08:35:38 | 显示全部楼层
汉字占两个字节,再加‘\0’就3个字节...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行