不知道utf8的这种url写法如何转换成正常字符。(加了双向转换的执行文件,c编译的)

系统字体配置、中文显示和输入法问题
回复
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

不知道utf8的这种url写法如何转换成正常字符。(加了双向转换的执行文件,c编译的)

#1

帖子 eexpress » 2006-07-23 15:21

/%E5%AA%92%E4%BD%93/
配置文件里面经常碰到这样的写法。
上次由 eexpress 在 2006-07-23 18:03,总共编辑 2 次。
● 鸣学
fteye
帖子: 201
注册时间: 2005-11-18 20:52
送出感谢: 0
接收感谢: 0

#2

帖子 fteye » 2006-07-23 15:30

头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

#3

帖子 eexpress » 2006-07-23 15:37

您已尝试访问地址 http://napoleo.spaces.msn.com/blog/cns! ... !224.entry ,它当前不可用。请确认您输入的网页地址和标点符号是否正确,然后再尝试重新载入此页面。
● 鸣学
头像
内存不足
论坛版主
帖子: 3277
注册时间: 2005-08-18 18:43
送出感谢: 0
接收感谢: 1 次
联系:

#4

帖子 内存不足 » 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
໌→ iCookie Gtk Theme
໌→DropPlusBluetheme
กรัก กรัก`菠萝
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

还代理才看到。

#5

帖子 eexpress » 2006-07-23 16:26

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的修改不方便,没其他的?
● 鸣学
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

看到这个

#6

帖子 eexpress » 2006-07-23 17:57

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。
● 鸣学
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙
送出感谢: 4 次
接收感谢: 256 次

#7

帖子 eexpress » 2006-07-23 18:01

编译的附件。

代码: 全选

$ 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) 下载 1489 次
● 鸣学
回复

回到 “字体美化和中文支持”