分页: 1 / 1
不知道utf8的这种url写法如何转换成正常字符。(加了双向转换的执行文件,c编译的)
发表于 : 2006-07-23 15:21
由 eexpress
/%E5%AA%92%E4%BD%93/
配置文件里面经常碰到这样的写法。
发表于 : 2006-07-23 15:30
由 fteye
发表于 : 2006-07-23 15:37
由 eexpress
发表于 : 2006-07-23 16:25
由 内存不足
. . . .
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
还代理才看到。
发表于 : 2006-07-23 16:26
由 eexpress
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的修改不方便,没其他的?
看到这个
发表于 : 2006-07-23 17:57
由 eexpress
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。
发表于 : 2006-07-23 18:01
由 eexpress
编译的附件。
代码: 全选
$ echo "file:///home/exp/%E5%AA%92%E4%BD%93/%E5%9B%BE%E7%89%87/baby-pic" | urldecode
file:///home/exp/媒体/图片/baby-pic