# SE-0243: Codepoint and Character Literals

**URL:** <https://forums.swift.org/t/se-0243-codepoint-and-character-literals/21188>\
**Category:** Proposal Reviews\
**Created:** [March 4, 2019, 3:45pm UTC](https://forums.swift.org/t/se-0243-codepoint-and-character-literals/21188 "2019-03-04T15:45:06Z")\
**Posts on this page:** 1\
**Showing post:** 268

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [March 17, 2019, 3:50am UTC](https://forums.swift.org/t/se-0243-codepoint-and-character-literals/21188/268 "2019-03-17T03:50:56Z")

</div>

> [@jawbroken](#):
>
> I'm arguing top-down here: if you tell me there's a single-quoted character-like literal in Swift I'm going to strongly presume it defaults to `Character` .

> [@RMJay](#):
>
> Single quoted literals should clearly default to Character,

It is difficult to see why single-quoted literals should be _presumed_ to default to `Character`, as no language offers such a syntax.

Here's how popular programming languages make use of single quotation marks:

### String

- Delphi/Object Pascal
- JavaScript
- MATLAB (`char` array)
- Python
- R
- SQL

### 'Raw' string

- Groovy
- Perl
- PHP
- Ruby

### Code unit/code point/Unicode scalar

- C: `int`
- C++: `char` (if literal is prefixed, it can be `char8_t`, `char16_t`, `char32_t`, or `wchar_t`)
- C#: `char` (16-bit)
- Java: `char` (16-bit)
- Kotlin: `Char` (16-bit)
- Go: `rune` (32-bit)
- Rust: `char` (32-bit)

In Go, a Unicode code point is known as a **rune** (a term now also adopted in .NET). In Rust, a Unicode scalar value is known as a **character** ; in Swift, it is known as a **Unicode scalar**. (A Unicode scalar value is any Unicode code point except high- and low-surrogate code points.)

As can be seen, Go and Rust use single quotation marks for what in Swift is known as a **Unicode scalar literal**.

**No language uses this notation for what in Swift is known as an extended grapheme cluster literal** (i.e., character literal).

[The version of Unicode supported, and therefore grapheme breaking, is a runtime concept.](https://forums.swift.org/t/pitch-string-gaps-and-missing-apis/20984/20) In other words, it is the version of the standard library linked at run time that determines whether a string's contents are one extended grapheme cluster (i.e., `Character`) or not.

Adding syntax to distinguish between a single character and a string that may contain zero or more such characters will enable only best-effort diagnostics at compile time. In other words, a dedicated extended grapheme cluster literal syntax can provide users no guarantees about grapheme breaking as it relates to the contents of the literal, because such knowledge cannot be "baked in" statically into the code.

---

_[View the full topic](https://forums.swift.org/t/se-0243-codepoint-and-character-literals/21188)._
