Re: [PATCH] Bug #46806 - mb_strimwidth

From: Date: Sat, 03 Jan 2009 16:42:32 +0000
Subject: Re: [PATCH] Bug #46806 - mb_strimwidth
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-42473@lists.php.net to get a copy of this message
Hi, This behavior seems strange, but the rationale of this function is that the (east asian) width of the resulting string does not exceed the specified value so that it would fit to a fixed sized box when rendered in the browser, assuming the string would be displayed with a monospace font. So, it is the document that is wrong. Regards, Moriyoshi (2008/12/31 1:24), Henrique M. Decaria wrote:
Hello guys, Looking in the subject mentioned bug report, it seems that the attached patch might do the trick and make the mb_strimwidth() function work as explained in the php manual (http://br2.php.net/mb_strimwidth). According to it, the function should trim up to the defined width and append the trimmarker, that being said, the following code should return "hello..." not "he..." echo mb_strimwidth('helloworld', 0, 5, '...', 'UTF-8'); The change in the file is:
-    pc.width = width - mkwidth;
+    pc.width = width;
I am not sure why there is this "- mkwidth" there, but it seems to be used to remove the last "mkwidth" characters from the trimmed string so it would be replaced with the trimmarker. It could be that the test file for this function is incorrect (i can't guarantee as I am having issues with Japanese characters here). So please, if you could have a look and see if it works as expected with this patch it would be great. Thanks, Henrique
-- -- moriyoshi

« previous php.internals (#42473) next »