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
Index: ext/mbstring/libmbfl/mbfl/mbfilter.c
===================================================================
RCS file: /repository/php-src/ext/mbstring/libmbfl/mbfl/mbfilter.c,v
retrieving revision 1.7.2.5.2.1.2.1
diff -u -r1.7.2.5.2.1.2.1 mbfilter.c
--- ext/mbstring/libmbfl/mbfl/mbfilter.c 1 Aug 2008 22:56:47 -0000
1.7.2.5.2.1.2.1
+++ ext/mbstring/libmbfl/mbfl/mbfilter.c 30 Dec 2008 16:12:32 -0000
@@ -1558,7 +1558,7 @@
mkwidth = mbfl_strwidth(marker);
}
pc.from = from;
- pc.width = width - mkwidth;
+ pc.width = width;
pc.outwidth = 0;
pc.outchar = 0;
pc.status = 0;
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php