c#通过unicode编码判断字符是否为中文示例分享
时间:2022-01-13 16:33:44
protected bool IsChineseLetter(string input,int index)
{
int code = 0;
int chfrom = Convert.ToInt32("4e00", 16); //范围(0x4e00~0x9fff)转换成int(chfrom~chend)
int chend = Convert.ToInt32("9fff", 16);
if (input != "")
{
code = Char.ConvertToUtf32(input, index); //获得字符串input中指定索引index处字符unicode编码
if (code >= chfrom && code <= chend)
{
return true; //当code在中文范围内返回true
}
else
{
return false ; //当code不在中文范围内返回false
}
}
return false;
}
标签:unicode编码,是否为中文
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java 数据结构深入理解ArrayList与顺序表
2023-02-15 14:24:07
![](https://img.aspxhome.com/file/2023/1/62501_0s.png)
Java SpringMVC数据响应超详细讲解
2022-04-08 15:10:26
![](https://img.aspxhome.com/file/2023/1/63161_0s.png)
java面向对象设计原则之合成复用原则示例详解
2023-11-09 16:55:51
![](https://img.aspxhome.com/file/2023/3/58893_0s.png)
java根据网络地址保存图片的方法
2021-09-01 18:37:02
C# Websocket连接实现wss协议
2022-09-02 08:20:41
浅谈java安全编码指南之死锁dead lock
2023-06-22 04:49:19
Spring Batch批处理框架使用解析
2021-12-24 03:41:19
C#的Excel导入、导出
2023-09-10 01:00:24
![](https://img.aspxhome.com/file/2023/7/74827_0s.png)
java GUI实现学生图书管理简单实例
2023-11-11 05:00:05
![](https://img.aspxhome.com/file/2023/9/58999_0s.png)
一文带你了解RabbitMQ消息转换器
2023-11-15 23:22:28
![](https://img.aspxhome.com/file/2023/4/64384_0s.jpg)
String.replaceAll方法详析(正则妙用)
2022-02-12 03:07:29
解决mybatis批量更新出现SQL报错问题
2023-11-29 04:12:47
![](https://img.aspxhome.com/file/2023/5/60155_0s.png)
Java多线程通信:交替打印ABAB实例
2022-04-08 06:57:28
IDEA实现添加 前进后退 到工具栏的操作
2021-08-30 21:34:48
![](https://img.aspxhome.com/file/2023/7/62687_0s.jpg)
Eclipse+Java+Swing实现学生成绩管理系统的实例代码
2022-12-14 15:35:04
![](https://img.aspxhome.com/file/2023/0/77170_0s.jpg)
Java SpringBoot整合shiro-spring-boot-starterqi项目报错解决
2022-11-07 03:27:02
![](https://img.aspxhome.com/file/2023/0/69650_0s.png)
startActivityForResult和setResult案例详解
2023-09-15 19:13:33
为什么Spring和IDEA都不推荐使用 @Autowired 注解
2023-12-08 17:54:44
![](https://img.aspxhome.com/file/2023/9/66029_0s.png)
BeanDefinition基础信息讲解
2022-03-23 23:48:37
java实战之桌球小游戏
2022-04-22 20:40:13
![](https://img.aspxhome.com/file/2023/6/66986_0s.jpg)