Re: sprintf and utf8



On Sat, Mar 30, 2002 at 01:14:02PM -0500, Owen Taylor wrote:
> 
>  * We are in fact assuming ASCII compatible locales. This 
>    is basically safe because pretty much everybody else
>    does too. So " " is " ", in ASCII, UTF-8, and the current
>    locale.
> 
>  * We also assume the results of %d and %g are ASCII.
>    This is not quite so safe as the previous assumption,
>    but I'm not aware of any locales that violate it.
>    ("Arabic-Indic" numerals are used for in some contexts
>    for Arabic, Farsi, etc, but the more familiar Arabic
>    numerals are also understood, and I believe, generally
>    used in technical contexts.)

	So, to be clear, encodings like Big5, euc*, and KOI8-R all are
ASCII compatible and sprintf %d to ASCII?  I'm not that familiar with
them, but aren't some of them multibyte?

>    (Though I'd like to replace it with a g_date_format()
>    that doesn't have the bizarre buffer handling of strftime())

	Sounds like a good plan :-)

>  * The one thing you have to watch out for is that 
>    %.Ns is not UTF-8 safe for some C libraries (GNU
>    libc has the bizarre that even though N is in 
>    bytes, it should fail if the string is not chopped
>    at an integral number of locale characters.) So,
>    it needs to be avoided.

	Okay.

Joel

-- 

"You must remember this:
 A kiss is just a kiss,
 A sigh is just a sigh.
 The fundamental rules apply
 As time goes by."

			http://www.jlbec.org/
			jlbec evilplan org



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]