ITPub博客

首页 > 应用开发 > IT综合 > 用C#檢查字符串中是否有Unicode字符

用C#檢查字符串中是否有Unicode字符

原创 IT综合 作者:tolyhuang 时间:2008-04-01 13:55:21 0 删除 编辑

[@more@]

///


/// 檢查strInput中是否有Unicode字符
///

/// 要檢查的字符串
/// true:有Unicode字符; false:沒有Unicode字符
public static bool CheckExistUnicode(string strInput)
{
int i = strInput.Length;
if (i == 0)
return false;

int j = System.Text.Encoding.Default.GetBytes(strInput).Length;

if (i != j)
return true;
else
return false;
}

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/9437124/viewspace-1001737/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-07-22

  • 博文量
    268
  • 访问量
    1468757