/%E5%AA%92%E4%BD%93/
配置文件里面经常碰到这样的写法。
不知道utf8的这种url写法如何转换成正常字符。(加了双向转换的执行文件,c编译的)
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
-
- 帖子: 201
- 注册时间: 2005-11-18 20:52
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
您已尝试访问地址 http://napoleo.spaces.msn.com/blog/cns! ... !224.entry ,它当前不可用。请确认您输入的网页地址和标点符号是否正确,然后再尝试重新载入此页面。
● 鸣学
- 内存不足
- 论坛版主
- 帖子: 3277
- 注册时间: 2005-08-18 18:43
- 联系:
. . . .
Spaces Get your own space | Subscribe to RSS feed | Tell a friend |
Search spaces
Sign in to the Microsoft Passport Network Learn
Leo 札记
Are you lonesome tonight?
Home | Profile Blog Lists
Blog
Previous entry: 如何给vim添加Delphi... Next entry: 免费取名的程序实现流程
July 17
手工将Utf-8编码的Url还原
2006年7月1日18时13分41秒
不用HttpUtility.DecodeUri方法将Utf-8编码的Url还原成字符串:
string str = "%E7%A5%9E%E5%9C%A3%E5%A5%A5%E6%9E%97%E5%8C%B9%E4%BA%9A%E4%B9%8B%E5%85%89";
string [] s = str.Split('%');
byte[] rz = new byte[ s.Length -1];
for(int i=1; i < s.Length ; i++)
{
rz[i-1] = byte.Parse(s,System.Globalization.NumberStyles.HexNumber);
}
string xx = System.Text.Encoding.UTF8.GetString(rz);
Console.WriteLine(xx);
Console.Read();
对于其它编码的Url只需选择相应的Encoding对象就行了。
Add a comment
2:27 PM | Permalink | Trackbacks (0) | Blog it
Permalink
Publish a comment
You must sign in using a Microsoft .NET Passport to publish a comment to this website. Sign in to the Microsoft Passport Network
Don't have a Passport? Get one today
Use my profile information
Name:
E-mail address (optional):
Your blog URL (optional):
Comment:
BoldItalicUnderlineInsert Link
Trackbacks
The trackback URL for this entry is:
Weblogs that reference this entry
# None
Learn
Help
x
Tips
Add a photo to a blog entryPrevent, allow, or delete comments about your blogQuote someone's blogCreate a list of your favorite blogsOrganize your blog with categoriesShare content from your spaceUse permalinks to link blog entries
FAQs
Add, delete, or restrict trackbacksChange the number of entries displayedDelete a blog entryReport offensive behaviorSee how many people are reading your blog
Did you know?
* You can create your own Space in three easy steps. With your own Space you can tell your own story, stay connected with friends and have fun. Click here to get started.
* You can explore someone's friends network by clicking on the explore friends link on their friends list. Discover new people and maybe even connect with old friends.
* You can leave comments on photos and make them come to life. Who's hot. What's cool. Where's fun. Tell them about it.
* You can find the most popular interests categories on Spaces. See what everyone else is into by clicking here.
Search Help
Search Help
©2006 Microsoft. Legal MSN Privacy Advertise Feedback Code of Conduct Report Abuse Help
Spaces Get your own space | Subscribe to RSS feed | Tell a friend |
Search spaces
Sign in to the Microsoft Passport Network Learn
Leo 札记
Are you lonesome tonight?
Home | Profile Blog Lists
Blog
Previous entry: 如何给vim添加Delphi... Next entry: 免费取名的程序实现流程
July 17
手工将Utf-8编码的Url还原
2006年7月1日18时13分41秒
不用HttpUtility.DecodeUri方法将Utf-8编码的Url还原成字符串:
string str = "%E7%A5%9E%E5%9C%A3%E5%A5%A5%E6%9E%97%E5%8C%B9%E4%BA%9A%E4%B9%8B%E5%85%89";
string [] s = str.Split('%');
byte[] rz = new byte[ s.Length -1];
for(int i=1; i < s.Length ; i++)
{
rz[i-1] = byte.Parse(s,System.Globalization.NumberStyles.HexNumber);
}
string xx = System.Text.Encoding.UTF8.GetString(rz);
Console.WriteLine(xx);
Console.Read();
对于其它编码的Url只需选择相应的Encoding对象就行了。
Add a comment
2:27 PM | Permalink | Trackbacks (0) | Blog it
Permalink
Publish a comment
You must sign in using a Microsoft .NET Passport to publish a comment to this website. Sign in to the Microsoft Passport Network
Don't have a Passport? Get one today
Use my profile information
Name:
E-mail address (optional):
Your blog URL (optional):
Comment:
BoldItalicUnderlineInsert Link
Trackbacks
The trackback URL for this entry is:
Weblogs that reference this entry
# None
Learn
Help
x
Tips
Add a photo to a blog entryPrevent, allow, or delete comments about your blogQuote someone's blogCreate a list of your favorite blogsOrganize your blog with categoriesShare content from your spaceUse permalinks to link blog entries
FAQs
Add, delete, or restrict trackbacksChange the number of entries displayedDelete a blog entryReport offensive behaviorSee how many people are reading your blog
Did you know?
* You can create your own Space in three easy steps. With your own Space you can tell your own story, stay connected with friends and have fun. Click here to get started.
* You can explore someone's friends network by clicking on the explore friends link on their friends list. Discover new people and maybe even connect with old friends.
* You can leave comments on photos and make them come to life. Who's hot. What's cool. Where's fun. Tell them about it.
* You can find the most popular interests categories on Spaces. See what everyone else is into by clicking here.
Search Help
Search Help
©2006 Microsoft. Legal MSN Privacy Advertise Feedback Code of Conduct Report Abuse Help
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
还代理才看到。
string str = "%E7%A5%9E%E5%9C%A3%E5%A5%A5%E6%9E%97%E5%8C%B9%E4%BA%9A%E4%B9%8B%E5%85%89";
string [] s = str.Split('%');
byte[] rz = new byte[ s.Length -1];
for(int i=1; i < s.Length ; i++)
{
rz[i-1] = byte.Parse(s,System.Globalization.NumberStyles.HexNumber);
}
string xx = System.Text.Encoding.UTF8.GetString(rz);
Console.WriteLine(xx);
Console.Read();
c的修改不方便,没其他的?
string [] s = str.Split('%');
byte[] rz = new byte[ s.Length -1];
for(int i=1; i < s.Length ; i++)
{
rz[i-1] = byte.Parse(s,System.Globalization.NumberStyles.HexNumber);
}
string xx = System.Text.Encoding.UTF8.GetString(rz);
Console.WriteLine(xx);
Console.Read();
c的修改不方便,没其他的?
● 鸣学
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
看到这个
echo "$query" | tr '&' '\n' | grep "^$1=" | head -1 | sed "s/.*=//" | urldecode
就是urldecode不知道在哪个包。
http://gnosislivre.org/~aurium/cgi-bin/urldeco 是用awk解决的。等于就是c解决方案。
http://thijs.dalhuijsen.com/my/sh/urlde ... 3%5D.shtml 是纯bash的写法。
都麻烦麻烦的。干脆自己编译一个urldecode.c。
就是urldecode不知道在哪个包。
http://gnosislivre.org/~aurium/cgi-bin/urldeco 是用awk解决的。等于就是c解决方案。
http://thijs.dalhuijsen.com/my/sh/urlde ... 3%5D.shtml 是纯bash的写法。
都麻烦麻烦的。干脆自己编译一个urldecode.c。
● 鸣学
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
编译的附件。
代码: 全选
$ echo "file:///home/exp/%E5%AA%92%E4%BD%93/%E5%9B%BE%E7%89%87/baby-pic" | urldecode
file:///home/exp/媒体/图片/baby-pic
- 附件
-
- [url-de-en-code](2006-07-23-18-04-16).tar.gz
- (4.28 KiB) 已下载 1539 次
● 鸣学