Convert ISO8859 1-16 Encoded Text to String in Swift.
letencoding=ISO8859.part1
letstring=String([...], iso8859Encoding: encoding)| Encoding | Name | Enum |
|---|---|---|
| ISO8859-1 | Latin 1 Western European | ISO8859.part1 |
| ISO8859-2 | Latin 2 Central European | ISO8859.part2 |
| ISO8859-3 | Latin 3 South European | ISO8859.part3 |
| ISO8859-4 | Latin 4 North European | ISO8859.part4 |
| ISO8859-5 | Latin/Cyrillic | ISO8859.part5 |
| ISO8859-6 | Latin/Arabic | ISO8859.part6 |
| ISO8859-7 | Latin/Greek | ISO8859.part7 |
| ISO8859-8 | Latin/Hebrew | ISO8859.part8 |
| ISO8859-9 | Latin 5 Turkish | ISO8859.part9 |
| ISO8859-10 | Latin 6 Nordic | ISO8859.part10 |
| ISO8859-11 | Latin/Thai | ISO8859.part11 |
| ISO8859-13 | Latin 7 Baltic Rim | ISO8859.part13 |
| ISO8859-14 | Latin 8 Celtic | ISO8859.part14 |
| ISO8859-15 | Latin 9 | ISO8859.part15 |
| ISO8859-16 | Latin 10 South-Eastern European | ISO8859.part16 |
iflet 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)}letturkishTextData=Data(bytes:[84,252,114,107,231,101])iflet string =String(turkishTextData, iso8859Encoding:ISO8859.part9){print(string) // Returns "Türkçe"
}letgreekTextbytes:[UInt8]=[0xE1,0xE2,0xE3,0xE4]iflet string =String(greekTextbytes, iso8859Encoding:ISO8859.part7){print(string) // Returns "αβγδ"
}Add ISO8859 as a dependency in your Package.swift file:
import PackageDescription
letpackage=Package(
dependencies:[.package(url:"https://github.com/Cosmo/ISO8859.git", from:"1.1.0"),])Just drag the source files into your project.
- Devran "Cosmo" Uenal
- Twitter: @maccosmo
- LinkedIn: devranuenal
- BinaryKit — BinaryKit helps you to break down binary data into bits and bytes and easily access specific parts.
- Clippy — Clippy from Microsoft Office is back and runs on macOS! Written in Swift.
- GrammaticalNumber — Turns singular words to the plural and vice-versa in Swift.
- HackMan — Stop writing boilerplate code yourself. Let hackman do it for you via the command line.
- SpriteMap — SpriteMap helps you to extract sprites out of a sprite map. Written in Swift.
- StringCase — Converts String to lowerCamelCase, UpperCamelCase and snake_case. Tested and written in Swift.
- TinyConsole — TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible.
ISO8859 is released under the MIT License.