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

TolyHuang發表於2008-04-01

[@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部落格 ” ,連結:http://blog.itpub.net/9437124/viewspace-1001737/,如需轉載,請註明出處,否則將追究法律責任。

相關文章