Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gumob/punycodeswift
PunycodeSwift is a pure Swift library to allows you to encode and decode punycoded strings
https://github.com/gumob/punycodeswift
carthage idna ios macos punycode swift-package-manager swift5 tvos visionos watchos
Last synced: 8 days ago
JSON representation
PunycodeSwift is a pure Swift library to allows you to encode and decode punycoded strings
- Host: GitHub
- URL: https://github.com/gumob/punycodeswift
- Owner: gumob
- License: mit
- Created: 2018-11-19T07:04:36.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-08-28T07:27:23.000Z (3 months ago)
- Last Synced: 2024-10-28T12:54:59.528Z (17 days ago)
- Topics: carthage, idna, ios, macos, punycode, swift-package-manager, swift5, tvos, visionos, watchos
- Language: Swift
- Homepage: https://gumob.github.io/PunycodeSwift/swiftdoc/
- Size: 292 KB
- Stars: 24
- Watchers: 3
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Swift Package Manager compatible](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange)](https://github.com/gumob/PunycodeSwift)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/gumob/PunycodeSwift)
[![Cocoapods Version](https://img.shields.io/cocoapods/v/Punycode.svg)](https://cocoapods.org/pods/Punycode)
[![Cocoapods Platform](https://img.shields.io/cocoapods/p/Punycode.svg)](https://cocoadocs.org/docsets/Punycode)
[![Build](https://github.com/gumob/PunycodeSwift/actions/workflows/main.yml/badge.svg)](https://github.com/gumob/PunycodeSwift/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/gumob/PunycodeSwift/branch/master/graph/badge.svg)](https://codecov.io/gh/gumob/PunycodeSwift)
![Language](https://img.shields.io/badge/Language-Swift%205.0-orange.svg)
![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg)# 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)](https://en.wikipedia.org/wiki/Punycode)
## Requirements
- macOS 10.13 or later
- iOS 12.0 or later
- tvOS 12.0 or later
- watchOS 4.0 or later
- visionOS 1.0 or later
- Swift 5.0 or later## Installation
### Swift Package Manager
Add the following to your `Package.swift` file.
- macOS, iOS, tvOS, watchOS, visionOS, and Swift 5
```swift
dependencies: [
.package(url: "https://github.com/gumob/PunycodeSwift.git", .upToNextMajor(from: "3.0.0"))
]
```- macOS, iOS, tvOS, and Swift 5
```swift
dependencies: [
.package(url: "https://github.com/gumob/PunycodeSwift.git", .upToNextMajor(from: "2.1.1"))
]
```### Carthage
Add the following to your `Cartfile` and follow [these instructions](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application).
- macOS, iOS, tvOS, watchOS, visionOS, and Swift 5
```
github "gumob/PunycodeSwift" ~> 3.0
```- macOS, iOS, tvOS, and Swift 5
```
github "gumob/PunycodeSwift" ~> 2.0
```- macOS, iOS, tvOS, and Swift 4
```
github "gumob/PunycodeSwift" ~> 1.0
```### CocoaPods
To integrate TLDExtract into your project, add the following to your `Podfile`.
- macOS, iOS, tvOS, watchOS, visionOS, and Swift 5.0
```ruby
pod 'Punycode', '~> 3.0'
```- macOS, iOS, tvOS, and Swift 5.0
```ruby
pod 'Punycode', '~> 2.0'
```- macOS, iOS, tvOS, and Swift 4.2
```ruby
pod 'Punycode', '~> 1.0'
```## Usage
Full documentation is available at [https://gumob.github.io/PunycodeSwift/swiftdoc/](https://gumob.github.io/PunycodeSwift/swiftdoc/).
### Encode and decode IDNA:
```swift
import Punycodevar sushi: String = "寿司"
sushi = sushi.idnaEncoded!
print(sushi) // xn--sprr0qsushi = sushi.idnaDecoded!
print(sushi) // "寿司"
```### Encode and decode Punycode directly:
```swift
import Punycodevar sushi: String = "寿司"
sushi = sushi.punycodeEncoded!
print(sushi) // sprr0qsushi = 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.