Latest 1.0.3
Homepage https://github.com/zh-wang/SwiftySurrogate
License MIT
Platforms ios 8.0, requires ARC
Authors

CI Status
Version
License
Platform

Usage

Use UTF16 surrogate easier in Swift.

    var emoji1 = SwiftySurrogate.decodeFromSurrogatePair(surrogatePair: "D83D:DCC9")
    var emoji2 = SwiftySurrogate.decodeFromSurrogatePair(high: 0xD83C, low: 0xDF80)

You can convert between surrogate pair to unicode scalar.

    expect("D83D:DE04") == "(SwiftySurrogate.convUnicodeScalarToSurrogatePair(0x1F604).0!.hexExpression()):(SwiftySurrogate.convUnicodeScalarToSurrogatePair(0x1F604).1!.hexExpression())"
    // true

    expect(UInt32(0x1F604)) == SwiftySurrogate.convSurrogateToUnicodeScalar("D83D:DE04")
    // true

Catch decoding error by optional check.

    // This will fail
    if let res = SwiftySurrogate.decodeFromSurrogatePair(surrogatePair: "FFFF:DE04") {

    } else {
        // Get the error
        println(SwiftySurrogate.lastError())
        // print -> Optional(Error Domain=SwiftySurrogateErrorDomain Code=504 "High Surrogates (FFFF) must be less than 0xDBFF" 
    }

Requirements

iOS 8.0

Installation

Cocoapods

pod "SwiftySurrogate"

Carthage

github "zh-wang/SwiftySurrogate" >= 1.0.1

Author

zh-wang, [email protected]

License

SwiftySurrogate is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftySurrogate",
    "version": "1.0.3",
    "summary": "Use UTF16 surrogate easier in Swift",
    "homepage": "https://github.com/zh-wang/SwiftySurrogate",
    "license": "MIT",
    "authors": {
        "zh-wang": "[email protected]"
    },
    "source": {
        "git": "https://github.com/zh-wang/SwiftySurrogate.git",
        "tag": "1.0.3"
    },
    "social_media_url": "https://twitter.com/viennakanon",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/*.{swift}"
}

Pin It on Pinterest

Share This