Bug #66254 [Opn->Fbk]: htmlentities does not convert single-byte katakana chars on Shift-JIS

From: Date: Sat, 04 Jan 2014 20:50:33 +0000
Subject: Bug #66254 [Opn->Fbk]: htmlentities does not convert single-byte katakana chars on Shift-JIS
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183592@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66254&edit=1

 ID:                 66254
 Updated by:         yohgaki@php.net
 Reported by:        charles123zelrax456 at yahoo dot com
 Summary:            htmlentities does not convert single-byte katakana
                     chars on Shift-JIS
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            mbstring related
 Operating System:   Linux
 PHP Version:        5.5.7RC1
 Block user comment: N
 Private report:     N

 New Comment:

I've tried on my Fedora19's PHP 5.5 and 5.6-dev with SJIS encoded PHP script and got

Original String:
。「」、・ヲァィゥェォャュョッ
ーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚アバ日本語
DOUBLEBYTE SINGLE BYTE<br>
Converted String:
。「」、・ヲァィゥェォャュョッ
ーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚アバ日本語
DOUBLEBYTE SINGLE BYTE&lt;br&gt;

Since you are using RC, I suppose you built PHP from source. What is your environment?


Previous Comments:
------------------------------------------------------------------------
[2013-12-10 02:30:46] charles123zelrax456 at yahoo dot com

Description:
------------
Japanese katakana characters can be encoded as single-byte especially when using mobile phones. Most
of the Japanese mobile sites use Shift-JIS encoding. For security purposes, htmlentities is used in
all user inputs. Unfortunately, when single-byte katakana strings encoded in Shift-JIS are passed in
htmlentities, garbage characters are returned.

Test script:
---------------
//make sure that the code as well as the browser settings are encoded also in Shift-JIS
$txt =
"。「」、・ヲァィゥェォャュョッ
ーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚アバ日本語
DOUBLEBYTE SINGLE BYTE<br>";
echo "Original String: " . $txt;
$new_txt = htmlentities($txt, ENT_QUOTES, "SJIS");
echo "<br>Converted String: " . $new_txt;

Actual result:
--------------
Original String:
。「」、・ヲァィゥェォャュョッ
ーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙゚アバ日本語
DOUBLEBYTE SINGLE BYTE

Converted String: ¡¢£¤¥¦§¨©ª«¬­®¯
°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßアバ日本語
DOUBLEBYTE SINGLE BYTE<br>


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66254&edit=1


Thread (3 messages)

« previous php.bugs (#183592) next »