Initial standalone code, some stuff runs
[sdl_omap.git] / test / utf8.txt
CommitLineData
e14743d1 1UTF-8 decoder capability and stress test
2----------------------------------------
3
4Markus Kuhn <http://www.cl.cam.ac.uk/~mgk25/> - 2003-02-19
5
6This test file can help you examine, how your UTF-8 decoder handles
7various types of correct, malformed, or otherwise interesting UTF-8
8sequences. This file is not meant to be a conformance test. It does
9not prescribes any particular outcome and therefore there is no way to
10"pass" or "fail" this test file, even though the texts suggests a
11preferable decoder behaviour at some places. The aim is instead to
12help you think about and test the behaviour of your UTF-8 on a
13systematic collection of unusual inputs. Experience so far suggests
14that most first-time authors of UTF-8 decoders find at least one
15serious problem in their decoder by using this file.
16
17The test lines below cover boundary conditions, malformed UTF-8
18sequences as well as correctly encoded UTF-8 sequences of Unicode code
19points that should never occur in a correct UTF-8 file.
20
21According to ISO 10646-1:2000, sections D.7 and 2.3c, a device
22receiving UTF-8 shall interpret a "malformed sequence in the same way
23that it interprets a character that is outside the adopted subset" and
24"characters that are not within the adopted subset shall be indicated
25to the user" by a receiving device. A quite commonly used approach in
26UTF-8 decoders is to replace any malformed UTF-8 sequence by a
27replacement character (U+FFFD), which looks a bit like an inverted
28question mark, or a similar symbol. It might be a good idea to
29visually distinguish a malformed UTF-8 sequence from a correctly
30encoded Unicode character that is just not available in the current
31font but otherwise fully legal, even though ISO 10646-1 doesn't
32mandate this. In any case, just ignoring malformed sequences or
33unavailable characters does not conform to ISO 10646, will make
34debugging more difficult, and can lead to user confusion.
35
36Please check, whether a malformed UTF-8 sequence is (1) represented at
37all, (2) represented by exactly one single replacement character (or
38equivalent signal), and (3) the following quotation mark after an
39illegal UTF-8 sequence is correctly displayed, i.e. proper
40resynchronization takes place immageately after any malformed
41sequence. This file says "THE END" in the last line, so if you don't
42see that, your decoder crashed somehow before, which should always be
43cause for concern.
44
45All lines in this file are exactly 79 characters long (plus the line
46feed). In addition, all lines end with "|", except for the two test
47lines 2.1.1 and 2.2.1, which contain non-printable ASCII controls
48U+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 the
51correct number of characters in every line, that is whether each
52malformed sequences is replaced by a single replacement character.
53
54Note that as an alternative to the notion of malformed sequence used
55here, it is also a perfectly acceptable (and in some situations even
56preferable) solution to represent each individual byte of a malformed
57sequence by a replacement character. If you follow this strategy in
58your decoder, then please ignore the "|" column.
59
60
61Here come the tests: |
62 |
631 Some correct UTF-8 text |
64 |
65(The codepoints for this test are: |
66 U+03BA U+1F79 U+03C3 U+03BC U+03B5 --ryan.) |
67 |
68You should see the Greek word 'kosme': "κόσμε" |
69 |
70 |
712 Boundary condition test cases |
72 |
732.1 First possible sequence of a certain length |
74 |
75(byte zero skipped...there's a null added at the end of the test. --ryan.) |
76 |
772.1.2 2 bytes (U-00000080): "\80" |
782.1.3 3 bytes (U-00000800): "ࠀ" |
792.1.4 4 bytes (U-00010000): "𐀀" |
80 |
81(5 and 6 byte sequences were made illegal in rfc3629. --ryan.) |
822.1.5 5 bytes (U-00200000): "" |
832.1.6 6 bytes (U-04000000): "" |
84 |
852.2 Last possible sequence of a certain length |
86 |
872.2.1 1 byte (U-0000007F): "\7f" |
882.2.2 2 bytes (U-000007FF): "߿" |
89 |
90(Section 5.3.2 below calls this illegal. --ryan.) |
912.2.3 3 bytes (U-0000FFFF): "￿" |
92 |
93(5 and 6 bytes sequences, and 4 bytes sequences > 0x10FFFF were made illegal |
94 in rfc3629, so these next three should be replaced with a invalid |
95 character codepoint. --ryan.) |
962.2.4 4 bytes (U-001FFFFF): "" |
972.2.5 5 bytes (U-03FFFFFF): "" |
982.2.6 6 bytes (U-7FFFFFFF): "" |
99 |
1002.3 Other boundary conditions |
101 |
1022.3.1 U-0000D7FF = ed 9f bf = "퟿" |
1032.3.2 U-0000E000 = ee 80 80 = "" |
1042.3.3 U-0000FFFD = ef bf bd = "�" |
1052.3.4 U-0010FFFF = f4 8f bf bf = "􏿿" |
106 |
107(This one is bogus in rfc3629. --ryan.) |
1082.3.5 U-00110000 = f4 90 80 80 = "" |
109 |
1103 Malformed sequences |
111 |
1123.1 Unexpected continuation bytes |
113 |
114Each unexpected continuation byte should be separately signalled as a |
115malformed sequence of its own. |
116 |
117