a lot of sites like google and wikipedia encode non-english characters in hex with a leading % sign. I looked for a tool that I could pipe URLs into it and, when such %AA strings are met, will translate these signs back to utf so that I can read them.
既然我找不到,我就把自己写进了正文,我想与大家分享,或许你会认为它有用:
#include <stdio.h>
int main()
{
char c;
unsigned int i;
while (!feof(stdin))
{
if (0==fread(&c,1,1,stdin)) break;
if (c!= % ) putchar(c);
else
{
if (scanf("%X",&i)==1) putchar(i);
else putchar( % );
}
}
return 0;
}
使用实例:
# echo "http://he.wikipedia.org/wiki/%D7%A2%D7%9E%D7%95%D7%93_%D7%A8%D7%90%D7%A9%D7%99" | ./dumpHex
results:
http://he.wikipedia.org/wiki/עמוד_ראשי