Skip to content

Instantly share code, notes, and snippets.

@martinhoeller
Created October 20, 2025 11:22
Show Gist options
  • Select an option

  • Save martinhoeller/fe7fd04dab618d48c3b226864b478930 to your computer and use it in GitHub Desktop.

Select an option

Save martinhoeller/fe7fd04dab618d48c3b226864b478930 to your computer and use it in GitHub Desktop.
An enum with Swift String space characters
import Foundation
public extension String {
enum Spaces {
/// U+0020
static let space = "\u{0020}"
/// U+00A0
static let nonBreakingSpace = "\u{00A0}"
/// U+1680
static let oghamSpaceMark = "\u{1680}"
/// U+2000
static let enQuad = "\u{2000}"
/// U+2001
static let emQuad = "\u{2001}"
/// U+2002
static let enSpace = "\u{2002}"
/// U+2003
static let emSpace = "\u{2003}"
/// U+2004
static let threePerEmSpace = "\u{2004}"
/// U+2005
static let fourPerEmSpace = "\u{2005}"
/// U+2006
static let sixPerEmSpace = "\u{2006}"
/// U+2007
static let figureSpace = "\u{2007}"
/// U+2008
static let punctuationSpace = "\u{2008}"
/// U+2009
static let thinSpace = "\u{2009}"
/// U+200A
static let hairSpace = "\u{200A}"
/// U+202F
static let narrowNoBreakSpace = "\u{202F}"
/// U+205F
static let mediumMathematicalSpace = "\u{205F}"
/// U+3000
static let ideographicSpace = "\u{3000}"
/// U+200B
static let zeroWidthSpace = "\u{200B}"
/// U+FEFF
static let zeroWidthNoBreakSpace = "\u{FEFF}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment