会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
随风
树欲静而风不止,随风而动
博客园
首页
新随笔
联系
订阅
管理
按位截取字符以及绑定xml内容到repeater上
# region 方法:
string
TransString(
string
,
int
)按字符串的实际长度截取定长字符串
public
static
string
TransString(
string
Str,
int
Length)
{
int
i
=
0
, j
=
0
;
foreach
(
char
Char
in
Str)
{
if
((
int
)Char
>
127
)
i
+=
2
;
else
i
++
;
if
(i
>
Length)
{
Str
=
Str.Substring(
0
, j)
+
"
"
;
break
;
}
j
++
;
}
return
Str;
}
# endregion
按位截取字符,会有半个位留下的情况
string
GetSubString(
string
origStr,
int
endIndex)
{
byte
[] bytes
=
System.Text.Encoding.GetEncoding(
"
gb2312
"
).GetBytes(origStr);
if
(endIndex
>=
bytes.Length)
return
origStr;
byte
[] subBytes
=
new
byte
[endIndex];
Array.Copy(bytes,
0
,subBytes,
0
,endIndex);
return
System.Text.Encoding.GetEncoding(
"
gb2312
"
).GetString(subBytes);
}
绑定xml的内容和属性
http://weblogs.asp.net/sonukapoor/archive/2004/05/10/129215.aspx
posted on
2005-02-25 00:29
tangle
阅读(
634
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部