惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
小众软件
小众软件
有赞技术团队
有赞技术团队
MyScale Blog
MyScale Blog
A
About on SuperTechFans
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Jina AI
Jina AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
博客园_首页
T
Troy Hunt's Blog
I
InfoQ
M
MIT News - Artificial intelligence
aimingoo的专栏
aimingoo的专栏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
博客园 - 司徒正美
Cloudbric
Cloudbric
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
D
Docker
Attack and Defense Labs
Attack and Defense Labs
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
博客园 - 聂微东
S
Security Affairs
Security Archives - TechRepublic
Security Archives - TechRepublic
WordPress大学
WordPress大学
N
News and Events Feed by Topic
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
H
Heimdal Security Blog
大猫的无限游戏
大猫的无限游戏
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
A
Arctic Wolf
J
Java Code Geeks
F
Full Disclosure
L
Lohrmann on Cybersecurity
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Project Zero
Project Zero
GbyAI
GbyAI
B
Blog
爱范儿
爱范儿

博客园 - lrary

JavaScript经典技巧 - lrary - 博客园 动态添加ASP.NET控件并绑定处理事件一例 - lrary - 博客园 脚本收藏 - lrary - 博客园 一些sql语句的详细解释[转] 特殊的DataGrid的绑定 - lrary - 博客园 纯脚本搞掂DataGrid表表头不动,表身滚动。(转摘) - lrary - 博客园 检验密码强度的JS类 - lrary - 博客园 数据库设计规范 V2.0 SQL语句特---殊统计(1) DataGrid 多行 DataGrid怎么产生一个分类的题头 AJAX 在.net的应用 sql怎么使用外连接 Asp.NET程序中常用的三十三种代码 根据区位得到汉字拼音首字母(c#) 认识ASP.NET配置文件Web.config Asp.net(C#)实现验证码功能 给Repeater、Datalist和Datagrid增加自动编号列 查找和统计页面上控件
检测含有中文字符串的实际长度
lrary · 2006-05-06 · via 博客园 - lrary

/// <summary>
  /// 检测含有中文字符串的实际长度
  /// </summary>
  /// <param name="str">字符串</param>
  private int len(string str)
  {
   System.Text.ASCIIEncoding n = new System.Text.ASCIIEncoding();
   byte[] b = n.GetBytes(str);
   int l = 0; // l 为字符串之实际长度
   for (int i=0;i <= b.Length-1;i++)
   {
    if (b[i] ==63) //判断是否为汉字或全脚符号
    {
     l++;
    }
    l++;
   }   return l;
  }