[pacman-dev] [Bug] using strlen with utf8
Hi, it seems as if the function strlen only counts the number of bytes within a given string and not the number of characters. In case of utf8 a character can have a length of one or two bytes. The attached screenshot show that in trans.c:337 the length is calculated wrong (because he counts the ü twice). When replacing ü with ue everything is right. Pierre -- http://www.archlinux.de
On 2/14/07, Pierre Schmitz <pierre@archlinux.de> wrote:
Hi,
it seems as if the function strlen only counts the number of bytes within a given string and not the number of characters. In case of utf8 a character can have a length of one or two bytes.
The attached screenshot show that in trans.c:337 the length is calculated wrong (because he counts the ü twice). When replacing ü with ue everything is right.
Good catch. Just made a CVS commit that should hopefully fix this issue. Let me know if you see it pop up anywhere else, the commit I made should fix all instances of it happening on the progress bars. -Dan
Am Mittwoch, 14. Februar 2007 16:55:58 schrieb Dan McGee:
Good catch. Just made a CVS commit that should hopefully fix this issue. Let me know if you see it pop up anywhere else, the commit I made should fix all instances of it happening on the progress bars.
I just compiled this new version, but it doesn`t change the output. Strange thing... -- http://www.archlinux.de
On 2/14/07, Pierre Schmitz <pierre@archlinux.de> wrote:
Am Mittwoch, 14. Februar 2007 16:55:58 schrieb Dan McGee:
Good catch. Just made a CVS commit that should hopefully fix this issue. Let me know if you see it pop up anywhere else, the commit I made should fix all instances of it happening on the progress bars.
I just compiled this new version, but it doesn`t change the output. Strange thing...
Damn, I'm seeing this too. Looks like that function doesn't work as expected, I'll have to do some further debugging or testing later. It may have something to do with gettext not sending it back as a wchar type or something... -Dan
On 2/14/07, Pierre Schmitz <pierre@archlinux.de> wrote:
Am Mittwoch, 14. Februar 2007 16:55:58 schrieb Dan McGee:
Good catch. Just made a CVS commit that should hopefully fix this issue. Let me know if you see it pop up anywhere else, the commit I made should fix all instances of it happening on the progress bars.
I just compiled this new version, but it doesn`t change the output. Strange thing...
Ok. I know where this problem stems from, and more or less how to fix it. However, it will require a bit of changing to get it to output right, and I don't want to make these kind of changes right before we release. It has to do with printf() being a byte-oriented output, so we need to do some conversion to a wchar_t based output in cases like this where character numbers are important and they aren't guaranteed to match up with the byte numbers. This bug should never go the other way (make the progress bar line too long), so I don't want to call this a critical bug. Are you fine with putting it off until the first 'bugfix' release? -Dan
participants (2)
-
Dan McGee
-
Pierre Schmitz