如何截取中英文混合的字符串中的一个字符?
mid函数好像只是用于英文,不能对中文起效。

解决方案 »

  1.   

    当串来处理吧。ascii大于等于0x80(十进制128)的属于中文的一部分。
      

  2.   

    那么具体怎么作?
    我没有安装msdn,麻烦你帮我查查~
      

  3.   

    for(int i = 0; i < str.GetLength(); i ++)
    {
        char c = str.GetAt(i);
        if(c < 0x80)
        {
            //是中文的一部分
        }
        else
        {
            //是英文或符号
        }
    }还是赶快装一个MSDN吧,这是正事
      

  4.   

    no. you must check buffer bytes by bytes.
    ms has a API named IsDbcsLeadByte. think you string is in szStrBuffer, end with \0.then char *p = (char *) &szStrBuffer[0];
    while ( *p)
    {
      if (::IsDbcsLeadByte(*p))
      {
         //... do you work here , it's a double byte char
         p+=2;
      }else
      { 
       //it's a single char
        p++;
      }
     }because isdbcsleadbyte work with Local, you code can run in various os.