Swiftpack.co - Package - TheAngryDarling/StringIANACharacterSetEncoding

String IANA Character Set Encoding

swift >= 4.0 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.

Prerequisites

Swift version 4.0 or greater

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 Knock YOCKOW

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: