UTF-8: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: UTF-8
| Old | New | Line | |
|---|---|---|---|
| 1 | + | UTF-8 (8-bit UCS/Unicode Transformation Format) is a variable-length character encoding for Unicode. Unicode characters U+0000 to U+007F are encoded simply as bytes 00h to 7Fh. This means that files and strings which contain only 7-bit [[ASCII]] characters have the same encoding under both ASCII and UTF-8. | |
| 2 | + | ||
| 3 | + | All characters \> U+007F are encoded as a sequence of several bytes, each of which has the two most significant bits set. No byte sequence of one character is contained within a longer byte sequence of another character. This allows easy search for substrings. The first byte of a multibyte sequence that represents a non-ASCII character is always in the range C0h to FDh and it indicates how many bytes follow for this character. All further bytes in a multibyte sequence are in the range 80h to BFh. This allows easy resynchronization and robustness. | |
| 4 | + | ||
| 5 | + | | Code points | 1st byte | 2nd byte | 3rd byte | 4th byte | most significant bits of the first byte of a multi-byte sequence | | | |
| 6 | + | |----|----|----|----|----|----|----| | |
| 7 | + | | U+0000..U+007F | 00..7F | | | | 0 | [[ASCII]] | | |
| 8 | + | | U+0080..U+07FF | C2..DF | 80..BF | | | 110 | - [[UTF-8 Latin characters]] | | |
| 9 | + | | U+0800..U+0FFF | E0 | A0..BF | 80..BF | | 1110 | | | |
| 10 | + | | U+1000..U+FFFF | E1..EF | 80..BF | 80..BF | | 1110 | - [[UTF-8 subscripts and superscripts]] | | |
| 11 | + | | U+10000..U+3FFFF | F0 | 90..BF | 80..BF | 80..BF | 11110 | | | |
| 12 | + | | U+40000..U+FFFFF | F1..F3 | 80..BF | 80..BF | 80..BF | 11110 | | | |
| 13 | + | | U+100000..U+10FFFF | F4 | 80..BF | 80..BF | 80..BF | 11110 | | | |
| 14 | + | ||
| 15 | + | UTF-8 byte Sequences | |
| 16 | + | ||
| 17 | + | ## UTF8 functions | |
| 18 | + | ||
| 19 | + | ### FreePascal | |
| 20 | + | ||
| 21 | + | The system unit contains some basic functions: | |
| 22 | + | ||
| 23 | + | - UnicodeToUtf8 | |
| 24 | + | - Utf8ToUnicode | |
| 25 | + | - UTF8Encode | |
| 26 | + | - UTF8Decode | |
| 27 | + | - AnsiToUtf8 | |
| 28 | + | - Utf8ToAnsi | |
| 29 | + | ||
| 30 | + | ### Lazarus | |
| 31 | + | ||
| 32 | + | Lazarus also contains UTF8 functions. For more details see [[LCL Unicode Support]] | |
| 33 | + | ||
| 34 | + | ## See also | |
| 35 | + | ||
| 36 | + | - [[LCL Unicode Support|Dealing with directory and filenames]] - UTF8 functions for files | |
| 37 | + | - [[LCL Unicode Support]] - UTF8 in graphical applications | |
| 38 | + | - [[Console Mode Pascal|Console mode Pascal: Unicode (UTF8) output]] - Showing UTF8 output in console mode/text mode programs | |
| 39 | + | - [[UTF8 strings and characters]] | |
| 40 | + | ||
| 41 | + | --- | |
| 42 | + | *From the Free Pascal wiki, page "UTF-8", as it stood on 2017-06-26 after a change by Djzepi, out of the wiki's dump of 2024-05-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).* | |
| 43 | + | Category: Unicode |
