在ASCII中使用CString::GetLength()的话,貌似没得问题,可是在Unicode中使用CString::GetLength()时,返回的是字符数而不是字节数....可是咱们知道在Unicode中字节数=字符数*2。windows
因此能够在程序中层架以下代码来加强通用性:url
int length = str.GetLength();spa
#ifdef _UNICODE.net
length *= sizeof(TCHAR);code
#endifblog