Latest 1.0.1
Homepage https://github.com/gumob/PunycodeSwift
License MIT
Platforms ios 9.3, osx 10.12, tvos 12.0, requires ARC
Frameworks Foundation
Authors

Carthage compatible
Version
Platform
Build Status
codecov
Language
Packagist

PunycodeSwift

PunycodeSwift is a pure Swift library to allows you to encode and decode punycoded strings by using String extension.

What is Punycode?

Punycode is a representation of Unicode with the limited ASCII character subset used for Internet host names. Using Punycode, host names containing Unicode characters are transcoded to a subset of ASCII consisting of letters, digits, and hyphen, which is called the Letter-Digit-Hyphen (LDH) subset. For example, München (German name for Munich) is encoded as Mnchen-3ya. (Wikipedia)

Requirements

  • iOS 9.3 or later
  • macOS 10.12 or later
  • tvOS 12.0 or later
  • Swift 4.2

* No plans to support tvOS 11 or earlier for now

Installation

Carthage

Add the following to your Cartfile and follow these instructions.

github "gumob/PunycodeSwift"

CocoaPods

To integrate Punycode into your project, add the following to your Podfile.

platform :ios, '9.3'
use_frameworks!

pod 'Punycode'

Usage

Encode and decode IDNA:

import Punycode

var sushi: String = "寿司"

sushi = sushi.idnaEncoded!
print(sushi)  // xn--sprr0q

sushi = sushi.idnaDecoded!
print(sushi)  // "寿司"

Encode and decode Punycode directly:

import Punycode

var sushi: String = "寿司"

sushi = sushi.punycodeEncoded!
print(sushi)  // sprr0q

sushi = sushi.punycodeDecoded!
print(sushi)  // "寿司"

Copyright

Punycode is released under MIT license, which means you can modify it, redistribute it or use it however you like.

Latest podspec

{
    "name": "Punycode",
    "version": "1.0.1",
    "summary": "A Pure Swift library for encode and decode punycoded strings supporting iOS, macOS, and tvOS.",
    "homepage": "https://github.com/gumob/PunycodeSwift",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "gumob": "[email protected]"
    },
    "frameworks": "Foundation",
    "requires_arc": true,
    "source": {
        "git": "https://github.com/gumob/PunycodeSwift.git",
        "tag": "1.0.1"
    },
    "source_files": "Source/*.{swift}",
    "platforms": {
        "ios": "9.3",
        "osx": "10.12",
        "tvos": "12.0"
    },
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This