[Typo3-dev] problem with JS escape() and UTF-8 (on IE)

Martin T. Kutschker Martin.no5pam.Kutschker at blackbox.n0spam.net
Mon Aug 30 10:02:23 CEST 2004


Martin T. Kutschker wrote:
> Hi!
> 
> I've encountered a problem in the BE (with my wizard) and it has been 
> reported for the FE as well (bug 227: getUpdateJS of the feAdmin_lib).

On a general level there are two ways to run into this problem:

* JS escape() -> PHP urldecode()
* PHP urlencode() -> JS unescape()

Solution one for newer browsers:

* encodeURIComponent() -> urldecode(); cs->conv($str,'utf-8',$cs)
* cs->conv($str,$cs,'utf-8); urlencode() -> decodeURIComponent()

This is save, but will only work for IE 5.5 and Mozilla (version ??, 
AFAIK 1.3 had support for it, I guess 1.0 also) and I don't know about 
Opera, Konqueror, etc.

The above conversion could perhaps only be applied if IE 5.5 or Mozilla 
is detected.

Solution one for "all" browsers:

* escape() -> cs->unescapeJS($cs,$unicode,$str)
* cs->escapeJS($cs,$unicode,$str) -> unescape()

$unicode is a flag is determinded by browser sniffing. It is triggered 
by IE 5.5 and Mozilla 1.5 or higher. Of course the JS-style conversion 
functions have to be written yet.

Both solutions are bit inconvenent as they require a bit more code then 
stated above, eg the browser sniffing part. So for real deployment I 
suggest also some wrapper functions, either general ones or one for BE 
and FE each.

Masi





More information about the TYPO3-dev mailing list