[Typo3-dev] recode vs iconv (was: Next version of Typo3)

Martin Kutschker Martin.T.Kutschker at blackbox.net
Fri Aug 29 17:51:35 CEST 2003


Hi!

recode_string occurs only on two places:

t3lib/class.t3lib_stdgraphic.php:

function recodeString($string) {
return $this->TTFLocaleConv ?
recode_string($this->TTFLocaleConv,$string) : $string;
}


typo3/template.php:

function recodeString($string) {
return $GLOBALS["TYPO3_CONF_VARS"]["GFX"]["TTFLocaleConv"] ?
recode_string($GLOBALS["TYPO3_CONF_VARS"]["GFX"]["TTFLocaleConv"],$string)
: $string;
}

The conversion code is defined here (as a recode "request" format):

t3lib/config_default.php:

"TTFLocaleConv" => "",

As an alternative iconv (which is availabe on Windows) could be used instead of recode. Unfortunately they take different arguments:

recode_string("src_chrset..dest_charset",$string);
iconv($src_chrset,$dest_charset,$string);

So you have to ways for a wrapper:

recodeString_v1($from,$to,$string) {
if (function_exists("iconv") {
return iconv($from,$to,$string);
}
elseif (function_exists("recode_string") {
return recode_string("$from..$to",$string);
}
else
return $string;
}

recodeString_v2($conv,$string) {
if (function_exists("recode") {
return recode_string($conv,$string);
}
elseif (function_exists("recode_string") {
$charset = split("..",$conv);
return recode_string($charset[0],$charset[1],$string);
}
else
return $string;
}

The former avoids the split, which should be faster in a general deployment (and given that iconv is more widespread than recode). But then something would have to be done about the format of TTFLocaleConv.

Masi 





More information about the TYPO3-dev mailing list