EncConv: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: EncConv
| Old | New | Line | |
|---|---|---|---|
| 1 | + | ## About | |
| 2 | + | ||
| 3 | + | **EncConv** is a package which gives unit EncConv, to convert text to/from UTF8. It was based on LazUtils' unit **LConvEncoding** , but API was changed and simplified. The list of supported encodings is the same as in LConvEncoding. | |
| 4 | + | ||
| 5 | + | Author: Alexey Torgashin | |
| 6 | + | ||
| 7 | + | License: MPL 2.0 | |
| 8 | + | ||
| 9 | + | ## Changes since LConvEncoding | |
| 10 | + | ||
| 11 | + | * LConvEncoding has string constants to identify encodings, and it checks for those strings on each encoding operation, which is little slow. EncConv has Enum to identify encodings. And it has array to access encoding/decoding functions, which is based on mentioned Enum. That is optimization. | |
| 12 | + | ||
| 13 | + | ``` | |
| 14 | + | type | |
| 15 | + | TEncConvId = ( | |
| 16 | + | eidUTF8, | |
| 17 | + | eidUTF8BOM, | |
| 18 | + | eidUCS2LE, | |
| 19 | + | eidUCS2BE, | |
| 20 | + | ||
| 21 | + | eidCP1250, | |
| 22 | + | eidCP1251, | |
| 23 | + | eidCP1252, | |
| 24 | + | eidCP1253, | |
| 25 | + | eidCP1254, | |
| 26 | + | eidCP1255, | |
| 27 | + | eidCP1256, | |
| 28 | + | eidCP1257, | |
| 29 | + | eidCP1258, | |
| 30 | + | ||
| 31 | + | eidCP437, | |
| 32 | + | eidCP850, | |
| 33 | + | eidCP852, | |
| 34 | + | eidCP861, | |
| 35 | + | eidCP865, | |
| 36 | + | eidCP866, | |
| 37 | + | eidCP874, | |
| 38 | + | ||
| 39 | + | {$IFnDEF encconv_noasian} | |
| 40 | + | eidCP932, | |
| 41 | + | eidCP936, | |
| 42 | + | eidCP949, | |
| 43 | + | eidCP950, | |
| 44 | + | {$ENDIF} | |
| 45 | + | ||
| 46 | + | eidISO1, | |
| 47 | + | eidISO2, | |
| 48 | + | eidISO3, | |
| 49 | + | eidISO4, | |
| 50 | + | eidISO5, | |
| 51 | + | eidISO7, | |
| 52 | + | eidISO9, | |
| 53 | + | eidISO10, | |
| 54 | + | eidISO13, | |
| 55 | + | eidISO14, | |
| 56 | + | eidISO15, | |
| 57 | + | eidISO16, | |
| 58 | + | ||
| 59 | + | eidCPMac, | |
| 60 | + | eidKOI8R, | |
| 61 | + | eidKOI8U, | |
| 62 | + | eidKOI8RU | |
| 63 | + | ); | |
| 64 | + | ``` | |
| 65 | + | ||
| 66 | + | * EncConv doesn't give the parameter to apply encoding to FPC String variable (this is feature of FPC 3). EncConv treats strings as UTF-8 strings (so after a conversion UTF-8->nnnnn is performed, string may not contain valid UTF-8 characters). It also means that OS encodings API (iconv on Unix, etc) is not used in conversions. | |
| 67 | + | ||
| 68 | + | * Main functions in EncConv unit are: | |
| 69 | + | ||
| 70 | + | ``` | |
| 71 | + | function EncConvFindEncoding(const s: string): TEncConvId; | |
| 72 | + | ||
| 73 | + | function EncConvertFromUTF8(const S: string; Enc: TEncConvId): string; | |
| 74 | + | function EncConvertToUTF8(const S: string; Enc: TEncConvId): string; | |
| 75 | + | ||
| 76 | + | function EncConvGetANSI: TEncConvId; | |
| 77 | + | function EncConvGetOEM: TEncConvId; | |
| 78 | + | ``` | |
| 79 | + | ||
| 80 | + | * String names of ISO-8859-x encodings were changed a little: 'iso88591' -> 'iso-8859-1' etc. | |
| 81 | + | ||
| 82 | + | ## Download | |
| 83 | + | ||
| 84 | + | GitHub: <https://github.com/Alexey-T/EncConv> | |
| 85 | + | ||
| 86 | + | --- | |
| 87 | + | *From the Free Pascal wiki, page "EncConv", as the Internet Archive kept it on 2025-01-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
