PDA

View Full Version : few modify when I using chinese(utf-8)


leoyue
05-24-2006, 05:33 PM
It's need to change few code, I try to list those modifytions here just as your referrence.

It's will also be useful if you use Korean , Japanese or other Mutile-Byte language.

correct me, if I'm wrong.

//Change1: admin/rte/funtions.php
//Problem: 1% chinese character will change to ? or ??
function rteSafe($strText) {
//returns safe code for preloading in the RTE

$translate = array(
"?" => "đ", // "‘" => "đ",
"?" => "ђ", // "Ñ" => "ђ",
);

$tmpString = StrTr($strText, $translate);
//$tmpString = $strText;

//convert all types of single quotes
//$tmpString = str_replace(chr(145), chr(39), $tmpString);
//$tmpString = str_replace(chr(146), chr(39), $tmpString);
//$tmpString = str_replace("'", "'", $tmpString);

//convert all types of double quotes
//$tmpString = str_replace(chr(147), chr(34), $tmpString);
//$tmpString = str_replace(chr(148), chr(34), $tmpString);
// $tmpString = str_replace("\"", "\"", $tmpString);

//replace carriage returns & line feeds
$tmpString = str_replace(chr(10), " ", $tmpString);
$tmpString = str_replace(chr(13), " ", $tmpString);

// $tmpString = str_replace(chr(273), "đ", $tmpString);

return $tmpString;
}

leoyue
05-24-2006, 05:36 PM
//Change2: include/db_conn.php
Add this in last line:
@mysql_query("SET NAMES 'utf8'",$connection);

Otherwise few character will displayed as '?'

tulee04
10-31-2006, 08:21 AM
I test in utf-8 and all the character ố in the post becomes Ủ#39; in Admin Article Management. What line of code should I add to the suguestion above to make the character display correctly.