检测字符串中是否有中文
2004-09-25 12:34
295 查看
[DllImport("KERNEL32.DLL", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
private static extern int WideCharToMultiByte(
uint CodePage,
uint dwFlags,
string lpWideCharStr,
int cchWideChar,
string lpMultiByteStr,
int cchMultiByte,
string lpDefaultChar,
int lpUsedDefaultChar);
private const uint CP_ACP=0x0;
public void IsHaveChinese()
{
string m_str="中ABC言语";
int nLen=WideCharToMultiByte(CP_ACP,0,m_str,m_str.Length,null,0,null,0);
if (m_str.Length != nLen)
{
MessageBox.Show("有中文字符。");
}
else
{
MessageBox.Show("没有中文字符。");
}
}
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
private static extern int WideCharToMultiByte(
uint CodePage,
uint dwFlags,
string lpWideCharStr,
int cchWideChar,
string lpMultiByteStr,
int cchMultiByte,
string lpDefaultChar,
int lpUsedDefaultChar);
private const uint CP_ACP=0x0;
public void IsHaveChinese()
{
string m_str="中ABC言语";
int nLen=WideCharToMultiByte(CP_ACP,0,m_str,m_str.Length,null,0,null,0);
if (m_str.Length != nLen)
{
MessageBox.Show("有中文字符。");
}
else
{
MessageBox.Show("没有中文字符。");
}
}
相关文章推荐
- 检测字符串中是否含有中文
- 检测字符串中是否包含汉字;检测字符串中只能包含:中文、数字、下划线(_)、横线(-)
- 检测字符串中是否有中文
- 检测字符串是否由纯英文,纯中文,中英文混合组成
- java实现检测是否字符串中包含中文
- 判断字符串是否有包含关系(包括中文,中文注意编码格式)
- 判断字符串中是否含有中文
- java判断获取到的中文字符串是否乱码
- iOS 判断字符串是否是纯中文字符以及字符串的范围
- 判断字符串是否包含字母、数字、中文
- c# 判断字符串中是否有中文(是否为纯Asiic)
- 在ASP.NET中检测含有中文字符串的实际长度
- python检测字符串是否只由数字组成
- 判断字符串中是否有中文
- JavaScript检测字符串中是否含有html标签实现方法
- 判断一个值是否在数组里,可以检测数字,字符串,json对象
- java 判断固定的中文字符串 判断字符串中是否包含固定的中文字符 String.indexOf(中文)
- php检测字符串是否含有重复或递增的字符
- 检测字符串是否相等
- Java判断字符串是否包含中文以及包含的中文个数