CString::GetLength
int GetLength( ) const;
Return Value
A count of the bytes in the string.
Remarks
Call this member function to get a count of the bytes in this CString object. The count does not include a null terminator.
For multibyte character sets (MBCS), GetLength counts each 8-bit character; that is, a lead and trail byte in one multibyte character are counted as two bytes.
Example
The following example demonstrates the use of CString::GetLength.
// example for CString::GetLength
CString s( "abcdef" );
ASSERT( s.GetLength() == 6 );
在多字节(ANSI)环境里面
int iCount = 0;
CString strMyString;
strMyString = _T("中文字符");
iCount = strMyString.GetLength(); //iCount = 8
strMyString = _T("English char");
iCount = strMyString.GetLength();//iCount = 12
strMyString = _T("混合char");
iCount = strMyString.GetLength();//iCount = 8
在这里,GetLength把中文字符当成两个字符来对待。这并不是很符合我们的逻辑。
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
在Unicode环境里面
int iCount = 0;
CString strMyString;
strMyString = _T("中文字符");
iCount = strMyString.GetLength(); //iCount = 4
strMyString = _T("English char");
iCount = strMyString.GetLength();//iCount = 12
strMyString = _T("混合char");
iCount = strMyString.GetLength();//iCount = 6 在这里,GetLength按我们正常的逻辑把中文字符也看成是一个字符来对待。具有国际通用性
在VS2008测试通过
CString::GetLength
转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
CString::Format
CString::Format// 看代码,针对format带参数列表的情况没整明白,于是开始百度,搜
cstring format ide Time 百度 -
CString基础
1、2、3、4、
CString bc 字符串 ico -
Android 对第三方apk系统签名
签名的意义 1. 为了保证程序开发人员的合法 2. 防止部分人通过使用同样的Package Name(包名)来混淆替换已安装的程序 3. 保证我们每次公布的版本号的一致性(保证签名一致才干升级) 签名的过程 1. 右键点击Android项目,选择Export(导出),弹出例如以下对
Android 对第三方apk系统签名 移动开发 Android 开发人员 版本号