#22041 [Fbk->Opn]: mb_substr produces "mojibake" on certain strings ...
| From: | jc at mega-bucks dot co dot jp | Date: | Wed, 05 Feb 2003 03:20:50 +0000 |
| Subject: | #22041 [Fbk->Opn]: mb_substr produces "mojibake" on certain strings ... | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-32160@lists.php.net to get a copy of this message | ||
ID: 22041
User updated by: jc@mega-bucks.co.jp
Reported By: jc@mega-bucks.co.jp
-Status: Feedback
+Status: Open
Bug Type: mbstring related
Operating System: Red Hat Linux 7.2
PHP Version: 4.3.0
New Comment:
Glad you could see the funny side of this bug report :) I did try very
hard to find a better example ... but couldn't get mb_substr to break
on anything else.
Why set internal encoding to eucJP-win? The data is from a database and
is in EUC-JP ...
When I entered the data into the DB if the were any illegal EUC-JP
characters it should have complained ...
And as you can see I can display the whole string as EUC-JP perfectly.
It's only *after* I use mb_substr() that the string becomes mojibake
...
Thanks!
Previous Comments:
------------------------------------------------------------------------
[2003-02-04 07:36:19] moriyoshi@php.net
LOL! It's indeed so OFFENSIVE I have no idea how to translate those
words to English. But perhaps you know what that means?
Ehm, first try setting the internal encoding to "eucJP-win".
------------------------------------------------------------------------
[2003-02-04 05:28:48] jc@mega-bucks.co.jp
First, sorry for any offensive japanese words. I can't read/write
japanese very well, and the error in mb_substr occurs on data from a
list of video titles ... I tried to find another less offensive example
but couldn't. I'm just posting this bug report in order to help ...
I am trying to use mb_substr on data I get from a postgreSQL DB and in
some cases mb_substr seems to cut the string in the middle of a
multibyte char .. which turns the "cut" char into mojibake ...
The DB is in EUC-JP and my internal encoding is set to EUC-JP in my
php.ini file ...
As you can see the last character of the string has been improperly cut
...
Here is my test program and output:
CODE:
<?php
require_once("db_functions/sql_query.inc");
$sql = "select maker_comment from products where id=12802";
$res = sql_query($sql);
$dat = pg_fetch_object($res);
$c = $dat->substr;
echo "String: <BR>";
echo $c ."<BR>";
$c = mb_substr($c, 0, 80);
echo "<BR> After cutting it ... <BR>";
echo $c ."<BR>";
?>
OUPUT:
COMMENT2:
¥¢¥ó¥°¥ë¤Î¡ÖĶ-¸Ô´Ö¤Î¥¢¥ó¥°¥ë¡×¥·¥ê¡¼¥º£Ä£Ø¡¢Â³¡¹Åо졪¤¿¤À¤ÎºÆÊÔ¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡ªÍ¾Ê¬¤Ê²è¤¬¤Ê¤¤
AFTER cutting it ...
¥¢¥ó¥°¥ë¤Î¡ÖĶ-¸Ô´Ö¤Î¥¢¥ó¥°¥ë¡×¥·¥ê¡¼¥º£Ä£Ø¡¢Â³¡¹Åо졪¤¿¤À¤ÎºÆÊÔ¤â¤Î¤Ç¤Ï¤¢¤ê¤Þ�
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22041&edit=1