Giter VIP home page Giter VIP logo

punycodeswift's Introduction

Carthage compatible Version Platform Build Status codecov Language 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 10.2 or later
  • Swift 4.2 or later

Installation

Carthage

Add the following to your Cartfile and follow these instructions.

github "gumob/PunycodeSwift"          # Latest (Swift 5.0)
github "gumob/PunycodeSwift" ~> 2.0   # Swift 5.0
github "gumob/PunycodeSwift" ~> 1.0   # Swift 4.2

CocoaPods

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

platform :ios, '9.3'
use_frameworks!

pod 'Punycode'             # Latest (Swift 5.0)
pod 'Punycode', '~> 2.0'   # Swift 5.0
pod 'Punycode', '~> 1.0'   # Swift 4.2

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.

punycodeswift's People

Contributors

brindy avatar gumob avatar kojirof avatar rlynch194 avatar twodayslate avatar yutomizutani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

punycodeswift's Issues

Typo in package name?

The main product is defined as Punnycode in the Package.swift. This made figuring out how to install it tricky.

punycodeEncoded and idnaEncoded inconsistency

Hi! Thanks a lot for your hard work on this project. I've discovered two interesting behaviours which you probably can be interested in:

  • .punycodeEncoded mistransforms goo.gl into goo.gl-, while .idnaEncoded gives correct goo.gl
  • .idnaEncoded mistransforms ᎻTТРՏ∶⫻⫻նᏞ․fR into xn--p1ad93g9a045z2uc92va61370ahkav069eeeapa while .punycodeEncoded gives s0ad81gqel44eegaq82fczdkzya41780doa7v (later is correct according to https://unicode.org/cldr/utility/idna.jsp)

Latest pod not published to cocoapods repo

The podspec in the repo matches the release version 2.0.0, however, it looks like it was never published to cocoapods.

Am unable to update to latest version using cocoapods (which I unfortunately am tied to using at the moment)

Generates warnings when used by extension/framework

Hi,

Thanks for this project, very useful.

There's a slight problem in that it generates a warning when used in a project with extensions or frameworks:

:-1: linking against a dylib which is not safe for use in application extensions: /Users/brindy/Projects/DuckDuckGo/iOS/Carthage/Build/iOS/Punycode.framework/Punycode

The solution is to check the "Allow app extension API only" on the target for iOS.

I can submit a PR for this once time allows.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.