C++ Logo


Advanced search

Re: [std-proposals] Remove multicharacter literals

From: Tom Honermann <tom_at_[hidden]>
Date: Wed, 6 Mar 2024 16:45:20 -0500
Multi-character literals are literals of the form 'abcd', are inherited
from C, and are not related to character encodings like UTF-16. They are
actually used, just not for the purposes of encoding text. They are
sometimes used to form a signature in file headers or network protocols.

For what it is worth, if C++ did not have them and someone were to
propose adding them, I would vote strongly against adding them due to
rather weak use cases and portability concerns. However, removal should
be motivated by technical arguments somewhat stronger than "these are


On 3/6/24 4:19 PM, veronica alphonso via Std-Proposals wrote:
> 1.
> These are weird to handle because they basically depend on how
> many characters can an int encode, which is
> implementation-defined, so to use these well in a cross-platform
> environment you have to uh... constrast the number of characters
> with the size & alignment of an int
> Multi-character literals are unreliable to encode into an int because
> these depend on the implementation-defined size of int to know how
> many characters you can encode into, which in my opinion, is horrible.
> Also, multi-character literals are unnecessary, most codebases use
> wide, UTF-16 or UTF32 encodings to encode multi-character literals
> appropriately (yes, i know wchar_t is less than ideal, but lets ignore
> that for now).
> I don't think this feature serves any purpose nowadays, and the few
> codebases that may still use it should remove its support and get into
> the more reliable approaches, so this feature can be deprecated once
> and for all.

Received on 2024-03-06 21:45:22