|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-07-21 10:19 UTC] tony2001@php.net
[2005-07-21 12:47 UTC] sniper@php.net
[2005-07-22 08:04 UTC] lars dot jensen at careercross dot com
[2005-11-13 20:47 UTC] moriyoshi@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 20:00:01 2025 UTC |
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);