?

Log in

No account? Create an account
Eyes

iconv-url.php

http://we.lv/iconv-url.php is an HTTP redirector that computes the destination URL by iconv-translating various components of a given URL.

This is most useful with Firefox quick searches for legacy web sites that expect query terms in some other encoding than UTF-8.  For example, the quick search URL“http://we.lv/iconv-url.php?from=utf-8&to=cp949&components=query&variables=query&url=http://dic.naver.com/search.naver?query=%s” would work for NAVER Dictionary, which expects its query term in CP949 (aka UHC).

(In case you weren't familiar with Firefox quick search, it's a custom bookmark with %s in the URL and given a bookmark keyword.  If the URL above had the keyword “nd”, entering “nd lookmeup” in the address bar would indeed look up “lookmeup” in NAVER Dictionary.  :D)

Usage

http://we.lv/iconv-url.php?<parameter>=<value>[&<parameter>=<value>...]

Parameters

url

URL to convert and redirect to.

components

URL components to translate, separate by commas.

Valid components are scheme, user, host, path, query and fragment, as in: scheme://user:pass@host/path?query#fragment.

The default list is: user,pass,query,fragment

variables

URL query variables to convert.  If not specified, all variables are converted.  Only values of variables are converted; variable names are left unchanged.

from, to

Character encodings to convert from/to, as would be specified to iconv(8).  Defaults to UTF-8.

Example

http://we.lv/iconv-url.php?from=UTF-8&to=CP949&components=query&variables=x2&url=http://example.com/target?x1=%ea%b0%80&x2=%ea%b0%80

redirects to:

http://example.com/target?x1=%ea%b0%80&x2=%b0%a1

Note that the query variable x1 left unchanged because the variables parameter is set to “x2”; if it were omitted altogether or set to “x1,x2”, the varaible x1 would also be translated.

Tags: ,

Comments