Home

Awesome

ISO8859

<img src="https://img.shields.io/badge/swift5-compatible-green.svg?style=flat" alt="Swift 5.1 compatible" /> <img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License MIT" />

Convert ISO8859 1-16 Encoded Text to String in Swift.

Usage

let encoding = ISO8859.part1
let string = String([...], iso8859Encoding: encoding)

See Examples

Supported Character Sets

EncodingNameEnum
ISO8859-1Latin 1 Western EuropeanISO8859.part1
ISO8859-2Latin 2 Central EuropeanISO8859.part2
ISO8859-3Latin 3 South EuropeanISO8859.part3
ISO8859-4Latin 4 North EuropeanISO8859.part4
ISO8859-5Latin/CyrillicISO8859.part5
ISO8859-6Latin/ArabicISO8859.part6
ISO8859-7Latin/GreekISO8859.part7
ISO8859-8Latin/HebrewISO8859.part8
ISO8859-9Latin 5 TurkishISO8859.part9
ISO8859-10Latin 6 NordicISO8859.part10
ISO8859-11Latin/ThaiISO8859.part11
ISO8859-13Latin 7 Baltic RimISO8859.part13
ISO8859-14Latin 8 CelticISO8859.part14
ISO8859-15Latin 9ISO8859.part15
ISO8859-16Latin 10 South-Eastern EuropeanISO8859.part16

Examples

File to Hebrew Text

if
    let path = Bundle.main.path(forResource: "Hebrew-Text", ofType: "txt"),
    let hebrewTextData = try? Data(contentsOf: URL(fileURLWithPath: path)),
    let string = String(hebrewTextData, iso8859Encoding: ISO8859.part8)
{
    print(string)
}

Data to Turkish Text

let turkishTextData = Data(bytes: [84, 252, 114, 107, 231, 101])
if let string = String(turkishTextData, iso8859Encoding: ISO8859.part9) {
    print(string) // Returns "Türkçe"
}

UInt8 Bytes-Array to Greek Text

let greekTextbytes: [UInt8] = [0xE1, 0xE2, 0xE3, 0xE4]
if let string = String(greekTextbytes, iso8859Encoding: ISO8859.part7) {
    print(string) // Returns "αβγδ"
}

Installation

Swift Package Manager

Add ISO8859 as a dependency in your Package.swift file:

import PackageDescription

let package = Package(
    dependencies: [
        .package(url: "https://github.com/Cosmo/ISO8859.git", from: "1.1.0"),
    ]
)

Manually

Just drag the source files into your project.

Contact

Other Projects

License

ISO8859 is released under the MIT License.