I'm coding a php program to translate the English in JoomFish into various languages, starting with Catalan. The program works okay on its own and displays the characters correctly when using:
meta http-equiv="Content-Type" content="text/html; charset=UTF-8
...
$trans = english_to_catalan($value);
$trans = fixEncoding($trans);
echo $trans
...
function fixEncoding($in_str)
{
$cur_encoding = mb_detect_encoding($in_str) ;
if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
return $in_str;
else
return utf8_encode($in_str);
}
But when I use
$query = sprintf("UPDATE jos_jf_content set value = '%s', where id=%s limit 1", mysql_real_escape_string($trans), mysql_real_escape_string($id));
The values in the jos_jf_content table have the funny characters?
http://www.villamenorca.com/ca/inici.html
I've encoded the value to utf8, so I'm guessing its something to do with the mysql_real_escape_string() function - any ideas?
Many thanks
Russ
Joomla/PHP/MySql newbie since 11-June-08
Joomla Version 1.5.14 with legacy 1.0
MySql Server version: 5.1.30
MySQL charset: UTF-8 Unicode (utf8)
MySQL Connection Collation: utf8_unicode_ci
PHP Version 5.2.9
Apache 2.2.11