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

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to