~ chicken-core (master) /tests/UTF-8-test.txt
1UTF-8 decoder capability and stress test2----------------------------------------34Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> - 2015-08-28 - CC BY 4.056This test file can help you examine, how your UTF-8 decoder handles7various types of correct, malformed, or otherwise interesting UTF-88sequences. This file is not meant to be a conformance test. It does9not prescribe any particular outcome. Therefore, there is no way to10"pass" or "fail" this test file, even though the text does suggest a11preferable decoder behaviour at some places. Its aim is, instead, to12help you think about, and test, the behaviour of your UTF-8 decoder on a13systematic collection of unusual inputs. Experience so far suggests14that most first-time authors of UTF-8 decoders find at least one15serious problem in their decoder using this file.1617The test lines below cover boundary conditions, malformed UTF-818sequences, as well as correctly encoded UTF-8 sequences of Unicode code19points that should never occur in a correct UTF-8 file.2021According to ISO 10646-1:2000, sections D.7 and 2.3c, a device22receiving UTF-8 shall interpret a "malformed sequence in the same way23that it interprets a character that is outside the adopted subset" and24"characters that are not within the adopted subset shall be indicated25to the user" by a receiving device. One commonly used approach in26UTF-8 decoders is to replace any malformed UTF-8 sequence by a27replacement character (U+FFFD), which looks a bit like an inverted28question mark, or a similar symbol. It might be a good idea to29visually distinguish a malformed UTF-8 sequence from a correctly30encoded Unicode character that is just not available in the current31font but otherwise fully legal, even though ISO 10646-1 doesn't32mandate this. In any case, just ignoring malformed sequences or33unavailable characters does not conform to ISO 10646, will make34debugging more difficult, and can lead to user confusion.3536Please check, whether a malformed UTF-8 sequence is (1) represented at37all, (2) represented by exactly one single replacement character (or38equivalent signal), and (3) the following quotation mark after an39illegal UTF-8 sequence is correctly displayed, i.e. proper40resynchronization takes place immediately after any malformed41sequence. This file says "THE END" in the last line, so if you don't42see that, your decoder crashed somehow before, which should always be43cause for concern.4445All lines in this file are exactly 79 characters long (plus the line46feed). In addition, all lines end with "|", except for the two test47lines 2.1.1 and 2.2.1, which contain non-printable ASCII controls48U+0000 and U+007F. If you display this file with a fixed-width font,49these "|" characters should all line up in column 79 (right margin).50This allows you to test quickly, whether your UTF-8 decoder finds the51correct number of characters in every line, that is whether each52malformed sequences is replaced by a single replacement character.5354Note that, as an alternative to the notion of malformed sequence used55here, it is also a perfectly acceptable (and in some situations even56preferable) solution to represent each individual byte of a malformed57sequence with a replacement character. If you follow this strategy in58your decoder, then please ignore the "|" column.596061Here come the tests: |62 |631 Some correct UTF-8 text |64 |65You should see the Greek word 'kosme': "κόσμε" |66 |672 Boundary condition test cases |68 |692.1 First possible sequence of a certain length |70 |712.1.1 1 byte (U-00000000): "