cplusplus / cplusplus/draft

[lex.charset] p5 The associated character type of a code unit is not clear

Open
#5,247 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[lex.charset] p5 just states

A code unit is an integer value of character type ([basic.fundamental]). Characters in a character-literal other than a multicharacter or non-encodable character literal or in a string-literal are encoded as a sequence of one or more code units, as determined by the encoding-prefix ([lex.ccon], [lex.string]);

What's the concrete character type? which determines the character type? We just say the characters will be encoded as a sequence of one or more code units, in other words, a sequence of integer values of the character type. The clear clarification of the character type is significant. Consider this example:

 auto c = 'ʉ'.

The Unicode code point value of the character ʉ is 289. [lex.ccon] p1 just states

A non-encodable character literal is a character-literal whose c-char-sequence consists of a single c-char that is not a numeric-escape-sequence and that specifies a character that either lacks representation in the literal's associated character encoding or that cannot be encoded as a single code unit.

So, whether it is a non-encodable character literal depends on:

  • lacks representation in the literal's associated character encoding
  • cannot be encoded as a single code unit

Assume that the first bullet is always false in a circumstance. So, whether ʉ is a non-encodable character literal depends on the range a code unit can represent, which means the representable values for the character type. we didn't explicitly specify the character type for the code unit of a different kind of character-literal or string-literal. Although, it is implied by the Type in the corresponding table.

Should we improve [lex.charset] p5 to make that meaning to be clearer?

A code unit is an integer value of character type ([basic.fundamental]). Characters in a character-literal other than a multicharacter or non-encodable character literal or in a string-literal are encoded as a sequence of one or more code units, as determined by the encoding-prefix ([lex.ccon], [lex.string]); where the character type of a code unit is specified by the type or element type.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read [lex.charset] paragraph 5 together with [lex.ccon] paragraph 1, [lex.string], and [basic.fundamental]. Check how the character type is currently implied by the relevant literal type tables. Done means the standard text clearly identifies the character type of code units without leaving the relationship to the encoding prefix ambiguous.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, tex
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.