On Thu, Jul 03, 2003 at 09:03:40PM +0200, Bruno Haible wrote:
> > But no one answered my original question; why are the format specifiers
> > for wide character functions different?
> 
> Here's the answer: So that the a given format specifier corresponds to a
> given argument type.
> 
>    Format specifier                Argument type
> 
>      %d                            int
>      %s                            char *
>      %ls                           wchar_t *
>      %c                            int (promoted from char)
>      %lc                           wint_t (promoted from wchar_t)

Changing between char and wchar_t at compile-time with macros (TCHAR) is a
hideous Windows hack.  If you really want to generalize it, you could fork
printf to have a TCHAR type, eg:

  const TCHAR *t = _T("abc");
  printf("%t, %t", t, _T("def"));

(%t probably has some meaning in printf that I don't know off the top of
my head; I'm not suggesting you actually do this.)  This type switching
is just a gross migration scheme, for programmers who want to distribute
both Unicode and ANSI versions of their programs (for Win9x compatibility).

I doubt this was the intent with the C wide functions having similar
parameters; that's just consistency.

-- 
Glenn Maynard
--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to