[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: INT_STRLEN_BOUND and locales with *printf
From: |
Eric Blake |
Subject: |
Re: INT_STRLEN_BOUND and locales with *printf |
Date: |
Tue, 08 Feb 2011 13:37:28 -0700 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7 |
On 02/08/2011 01:34 PM, Ben Pfaff wrote:
> The INT_STRLEN_BOUND macro in Gnulib's intprops.h calculates the
> maximum number of bytes in a formatted integer, on the basis that
> the minus sign and each digit will occupy one byte. If *printf
> is used for formatting integers, is this a good assumption
> outside of the C locale? I do not see anything in the C or POSIX
> standards that say whether or not %d and similar format
> specifiers are allowed to use localized sign and digits.
>
> It looks to me that glibc only localizes the results of integer
> format specifiers if the glibc-specific "I" flag is present. I
> don't know whether that is true in every libc.
Good question. Right now, INT_STRLEN_BOUND assumes that you will be
outputting only in the C locale ('-' is one byte, and "%'d" does not
result in thousands separators); we would definitely need to modify
things to accommodate alternate locales.
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature