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

推荐订阅源

MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
雷峰网
雷峰网
V
Visual Studio Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
爱范儿
爱范儿
IT之家
IT之家
Engineering at Meta
Engineering at Meta
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
月光博客
月光博客
A
About on SuperTechFans
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
Blog — PlanetScale
Blog — PlanetScale

博客园 - 荷梅月剑

分布式应用(Distributed Application) ActiveReports:打印参数设置 ActiveReports 按组分页 在ActiveReport中显示页码 eclipse显示行数 JAVA延时 - 荷梅月剑 - 博客园 初学Java多线程:线程的生命周期 java多线程例子 Api函数声明的格式 - 荷梅月剑 - 博客园 说实话,我更喜欢当一个程序员 Rational Rose 2003 下载及破解方法 不可替代性 爱的链条,让人有所启发的故事 上学与不上学的区别(奇文共赏) jQuery获得各种控件Value的方法 Lc.exe已退出,代码为-1 的解决方法 使用UNIQUEIDENTIFIER做为主键 返回值的解决方法 EasyUi tabs的高度与宽度何根据IE窗口的变化自适应 - 荷梅月剑 - 博客园 再回博客园
计算出中文字串的实际长度
荷梅月剑 · 2007-12-06 · via 博客园 - 荷梅月剑

计算出中文字串的实际长度

Posted on 2007-12-06 13:51  荷梅月剑  阅读(214)  评论()    收藏  举报

private int strlen(string arg_strSource)
{
    int intStringLength = 0; //字串實際長度
    if(arg_strSource.Length > 1)
    {
        System.Text.ASCIIEncoding objAscII = new System.Text.ASCIIEncoding();
        byte[] ary_bteStringBuffer = objAscII.GetBytes(arg_strSource);
        for (int i=0 ; i <= ary_bteStringBuffer.Length-1 ; i++)
        {
            if (ary_bteStringBuffer[i] == 63) //判斷是否為中文字或全型符號
            {
                intStringLength++;
            }
            intStringLength++;
        }
    }    
    return intStringLength;
}