# Prepitch: Character integer literals

**URL:** <https://forums.swift.org/t/prepitch-character-integer-literals/10442>\
**Category:** Pitches\
**Created:** [February 28, 2018, 11:08pm UTC](https://forums.swift.org/t/prepitch-character-integer-literals/10442 "2018-02-28T23:08:40Z")\
**Posts on this page:** 1\
**Showing post:** 262

<div class="post-metadata">

**Author:** ![michelf](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/michelf/32/1180_2.png) [@michelf](https://forums.swift.org/u/michelf)\
**Post date:** [January 10, 2019, 1:36pm UTC](https://forums.swift.org/t/prepitch-character-integer-literals/10442/262 "2019-01-10T13:36:37Z")

</div>

I'd like to propose a _radically_ different approach — inspired from the concerns about non-ASCII characters:

- double quotes mean Unicode string, character, or scalar
- single quotes mean ASCII string or scalar

So whenever you need to be sure something is purely ASCII you use single-quotes:

```swift
let a: String = "planté" // unicode string
let b: String = 'planté' // ERROR: é is not ascii
let c: String = 'plante' // ascii string (no é in this one)

```

```swift
let a: Character = "é" // U+00E9
let b: Character = 'é' // ERROR: U+00E9 is not ascii
let c: Character = 'p' // U+0070

```

```swift
let a: UnicodeScalar = "é" // U+00E9
let b: UnicodeScalar = 'é' // ERROR: U+00E9 is not ascii
let c: UnicodeScalar = 'p' // U+0070

```

We can then allow ASCII literals to initialize any numeric type:

```swift
let a: UInt32 = "é" // ERROR: UInt32 does not conform to ExpressibleByUnicodeScalarLiteral
let b: UInt32 = 'é' // ERROR: U+00E9 is not ascii
let c: UInt32 = 'p' // 0x00000070

```

```swift
let a: UInt16 = "é" // error: UInt16 does not conform to ExpressibleByUnicodeScalarLiteral
let b: UInt16 = 'é' // error: U+00E9 is not ascii
let c: UInt16 = 'p' // 0x0070

```

```swift
let a: UInt8 = "é" // ERROR: UInt8 does not conform to ExpressibleByUnicodeScalarLiteral
let b: UInt8 = 'é' // ERROR: U+00E9 is not ascii
let c: UInt8 = 'p' // 0x70

```

And you can also initialize an array of numbers from an ASCII string:

```swift
let a: [UInt8] = "plante" // ERROR: Array does not conform to ExpressibleByStringLiteral
let b: [UInt8] = 'plante' // ascii

```

```swift
let a: [UInt16] = "plante" // ERROR: Array does not conform to ExpressibleByStringLiteral
let b: [UInt16] = 'plante' // ascii

```

Of course, this approach completely flips on its head the current character literal proposal.

---

_[View the full topic](https://forums.swift.org/t/prepitch-character-integer-literals/10442)._
