I install a Zenphoto on my server. And I saw that in themes don't have a encoding declaration:
` (my server send all pages inISO-8859-2`). Polish chars are broken.
And I saw that Ajax script to add a titles and description save a polish chars (?, ?, ?, ?, ?, ó, ?, ?...) bad.
Example:
Quote:?a?ó?? ?ó?t? ja??
changing to:
Quote:Za%u017Có%u0142%u0107 %u017Có%u0142t%u0105 ja%u017A%u0144
add to beginning of template-functions.php
`
/**
Function converts an Javascript escaped string back into a string with specified charset (default is UTF-8).
Modified function from http://pure-essence.net/stuff/code/utf8RawUrlDecode.phps
@param string $source escaped with Javascript's escape() function
@param string $iconv_to destination character set will be used as second paramether in the iconv function. Default is UTF-8.
@return string
*/
function unescape($source, $iconv_to = 'UTF-8') {
$decodedStr = '';
$pos = 0;
$len = strlen ($source);
while ($pos < $len) {
$charAt = substr ($source, $pos, 1);
if ($charAt == '%') {
$pos++;
$charAt = substr ($source, $pos, 1);
if ($charAt == 'u') {
// we got a unicode character
$pos++;
$unicodeHexVal = substr ($source, $pos, 4);
$unicode = hexdec ($unicodeHexVal);
$decodedStr .= code2utf($unicode);
$pos += 4;
}
else {
// we have an escaped ascii character
$hexVal = substr ($source, $pos, 2);
$decodedStr .= chr (hexdec ($hexVal));
$pos += 2;
}
}
else {
$decodedStr .= $charAt;
$pos++;
}
}
if ($iconv_to != "UTF-8") {
$decodedStr = iconv("UTF-8", $iconv_to, $decodedStr);
}
return $decodedStr;
}
/**
Function coverts number of utf char into that character.
Function taken from: http://sk2.php.net/manual/en/function.utf8-encode.php#49336
@param int $num
@return utf8char
*/
function code2utf($num){
if($num6)+192).chr(($num&63)+128);
if($num>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128);
if($num>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128);
return '';
}
`
then change stripslashes($newtitle) to stripslashes(unescape($newtitle))
and stripslashes($newdesc) to stripslashes(unescape($newdesc)).
and don't forget to add meta content-type = utf-8
Easy solution for non-english users.
add
header("Content-type: text/html; charset=utf-8");
into zp/index.php in the first line to override the default charset.
in Sajax.php, replace "escape" with "encodeURIComponent".
It works very well for Chinese characters.
http://blog.dukechina.org/gallery/
Shouldn't a simple htmlentities() PHP function change any special character to a valid html entity? I mean it converts all applicable characters to HTML entities. http://fi.php.net/htmlentities . I just don't know where to put this so that it would convert the text to html entities BEFORE it's saved to the database. I need Finnish/Scandinavian characters and they're coming out as just blocks or question marks. Help, please. Where could I put this?
Oh, but this doesn't work for Russian language... shit =)
It still shows all scandinavian letters (ä,å,ö) as question marks in File Info and Tags. Does anyone know what to do for this?