首页 | 资讯中心 | 软件分类 | 最近更新 | 推荐软件 | 热门软件 | 国产软件 | 国外软件 | 网络安全 | 病毒防治 | 用户注册 | 用户登陆
设为主页
收藏本站
联系我们
| 软件报道 | 软件教程 | 设计学院 | 硬件报道 |
软件搜索:   小容美容 广州购物 软件论坛
当前位置:ITPCHOME.COM-最新软件下载站文章首页软件教程编程开发→中英文混合字符截取函数
中英文混合字符截取函数
作者:不详  来源于:ITPCHOME-最新软件下载站  发布时间:2007-2-23 16:24:00

 
/* C# 解决办法 */

/**
* get sub-string from a ANSI encoded string
* @param str ANSI encoded string
* @param offset the offset of string to be truncated
* @param len the length of sub-string
* @return sub-string truncated from @param str
*/

public static string GetSubString(string str, int offset, int len)
{
if (str == null || str == "") return str;
if (len <= 0) return "";

StringBuilder builder = new StringBuilder();
int j = 0, count = 0;

for (int i = 0; i < str.Length; i++)
{
if (j >= offset)
{
builder.Append(str[i]);
count++;
if ((((int)str[i]) & 0xff00) > 0) count++;
}

j++;
if ((((int)str[i]) & 0xff00) > 0) j++;

if (count >= len) break;
}

return builder.ToString();
}

'ASP解决方法
Function msglength(msg,length)
if msg="" or isnull(msg) or IsNumeric(length)=False then
msglength=""
Exit Function
else
length=int(length)
j=0
for ii=1 to len(msg)
if asc(mid(msg,ii,1))>0 then j=j+1 else j=j+2
if j>length*2 then exit for
next
if j<=length*2 then msglength=msg else msglength=left(msg,ii-1)&""
end if
End function


[] [返回上一页] [告诉好友] [发表评论] [打 印] [ 字体: ]
上篇文章:.NET读取QQWry.Dat 纯真版ip数据库格式数据源 
下篇文章:php程序读取QQwry.dat
∷相关文章∷
· 在微软拼音2003中巧妙实现中英文混合输入
∷相关软件∷
关于本站 - 下载声明 - 软件发布 - 下载帮助 - 广告联系 - 友情连接 - 赞助本站继续发展
谦逊软件下载站(ITPCHOME)版权所有 Copyright © 2001-2008 粤ICP备05128692号 ITpchome.Com. All Rights Reserved .