Re: URL conversion from %?? to UTF-8
On Sat, Sep 19, 2009 at 04:45:18PM +0300, Teemu Likonen wrote:
> On 2009-09-19 08:39 (+0900), Osamu Aoki wrote:
>
> > I am looking for a method to convert URL with non-ascii character
> >
> > from
> >
> > http://fr.wikipedia.org/wiki/Param%C3%A8tres_r%C3%A9gionaux
> >
> > to
> >
> > http://fr.wikipedia.org/wiki/Paramètres_régionaux
> >
> > with some short script or command. What is the easiest way?
>
> The simplest is probably a script like this:
>
> #!/bin/bash
> printf '%b\n' "${1//%/\\x}"
>
> Give URL as the first argument.
Good idea! Thanks.
If I use dash, this does not work....
$ cat urlutf8
#!/bin/dash
/usr/bin/printf '%b\n' "$(/usr/bin/printf "%s" $1 |sed 's/\%/\\x/g')"
$ ./urlutf8
"http://fr.wikipedia.org/wiki/Param%C3%A8tres_r%C3%A9gionaux"
http://fr.wikipedia.org/wiki/Paramètres_régionaux
Not bad either.
I will use this for my Debian Reference build script.
Reply to: