Skip to content
IANA Character Set Encoding Conversion
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Sources
Tests
.gitignore
LICENSE.md
Package.swift
README.md

README.md

String IANA Character Set Encoding

Swift macOS Linux Apache 2

Adds the ability of taking an IANA encoding name and converting it into a String.Encoding object.

This package uses the CFStringConvertIANACharSetNameToEncoding and CFStringConvertEncodingToNSStringEncoding methods.

Usage

let ianaEncodingName: String = "UTF8"
guard let encoding = String(IANACharSetName: ianaEncodingName) else { 
    throw Error.InvalidEncoding(ianaEncodingName)
}

_ = encoding.IANACharSetName
_ = encoding.noDashIANACharSetName

Author

License

This project is licensed under Apache License v2.0 - see the LICENSE.md file for details

Acknowledgments

Stack Overflow resposne from rmaddy Patch for swift retain on swift versions 4.0, 4.1 provided on Swift Bugs by Knock YOCKOW

You can’t perform that action at this time.