C++ Logo

std-proposals

Advanced search

Re: [std-proposals] New printf/scanf modifiers

From: Tom Honermann <tom_at_[hidden]>
Date: Tue, 31 Jan 2023 22:57:59 -0500
There is an existing WG14 paper that seeks to add support for char8_t,
char16_t, and char32_t. It did not make the cut off for C23, but I
expect it to be considered for the following C standard.

N3016: Unicode Length Modifiers v3
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3016.pdf>

The C and C++ standards are not aware of TCHAR, so specifying a modifier
for it would be out of scope for these standards.

Tom.

On 1/31/23 1:40 PM, Lee Shallis via Std-Proposals wrote:
> since hh, h, etc are unused I decided to use them in my own
> implementation (separate name to standard printf) and just now thought
> to suggest them.
>
> hh = char8_t (In my equivalent typedef I chose to default to wchar_t
> when char is too small in a non standards compliant implementation)
> h = char16_t
> ll = char32_t (since l is reserved for wchar_t and the lack thereof for char)
> t = tchar_t (TCHAR on windows and char on linux)
> j = char32_t (since that's currently the biggest there is, we never
> know if we'll ever need bigger, for example space alien character sets
> - assuming they exist)
>
> I also used v as a modifier for intptr_t/uintptr_t, took it from void*
>
> Also I think .* should be used to indicate the max characters to scan
> for any string, for example
>
> #define LENG 7
> char name[LENG+1] = "";
> scanf("%.*s",LENG,name);
>
> With the input of "Hello world!" would give "Hello w"

Received on 2023-02-01 03:58:03