随风
树欲静而风不止,随风而动
博客园
首页
社区
新随笔
联系
订阅
管理
随笔-19 评论-6 文章-5 trackbacks-0
2005年2月25日
按位截取字符以及绑定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 @ 2005-02-25 00:29 tangle 阅读(413) 评论(0)
编辑
昵称:
tangle
园龄:
7年9个月
粉丝:
14
关注:
32
<
2005年2月
>
日
一
二
三
四
五
六
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
搜索
常用链接
我的随笔
我的评论
我的参与
最新评论
我的标签
随笔分类
Ajax(2)
Asp.net 2.0学习笔记
Dottext 点滴(6)
点滴心得(7)
随笔档案
2005年8月 (1)
2005年7月 (2)
2005年6月 (1)
2005年2月 (2)
2005年1月 (3)
2004年12月 (4)
2004年11月 (4)
2004年5月 (2)
最新评论
阅读排行榜
评论排行榜
推荐排行榜