From:             lars dot jensen at careercross dot com
Operating system: FreeBSD 5.3
PHP version:      5.0.3
PHP Bug Type:     mbstring related
Bug description:  Mojibake produced when converting utf-8 to sjis with certain 
characters

Description:
------------
Writing a class to handle conversion of UTF-8 input into SJIS using usual

$body = mb_convert_encoding($body, "SJIS", "UTF-8");
function, usually works, but so far by testing, I identified three kanji's
which makes this function fail to convert these correctly and thus causing
mojibake

The three UTF-8 characters is identified as follows 
chr(227).chr(136).chr(177)
chr(227).chr(136).chr(178)
chr(227).chr(136).chr(185)

which in SJIS corresponds to
chr(135).chr(138)
chr(135).chr(139)
chr(135).chr(140)

Reproduce code:
---------------
I created a "quick'n'dirty" solution as follows, which surely isnt
optimal

$body = str_replace(chr(227).chr(136).chr(177), '#mojihack1#', $body);
$body = str_replace(chr(227).chr(136).chr(178), '#mojihack2#', $body);
$body = str_replace(chr(227).chr(136).chr(185), '#mojihack3#', $body);

$body = mb_convert_encoding($body, "SJIS", "UTF-8");

$body = str_replace('#mojihack1#', chr(135).chr(138), $body);
$body = str_replace('#mojihack2#', chr(135).chr(139), $body);
$body = str_replace('#mojihack3#', chr(135).chr(140), $body);



-- 
Edit bug report at http://bugs.php.net/?id=33793&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33793&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33793&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33793&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33793&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33793&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33793&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33793&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33793&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33793&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33793&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33793&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33793&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33793&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33793&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33793&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33793&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33793&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33793&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33793&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33793&r=mysqlcfg

Reply via email to