X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=utf8.c;h=06a651ac5fada4e3cbdc6e9629c2b1deade8abc5;hp=6089df19038bfa171b2b1c4352e8f1ee58eb3dff;hb=ba0ac9737272ac247c1850be891b51c446144732;hpb=3e362e872c0596ff3e058c791a416ac7f8ae4c67 diff --git a/utf8.c b/utf8.c index 6089df1..06a651a 100644 --- a/utf8.c +++ b/utf8.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012, 2013 + * Copyright (C) 2012, 2013, 2014 * Dale Weiler * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -50,42 +50,31 @@ * In this table the transition values are pre-multiplied with 16 to * save a shift instruction for every byte, we throw away fillers * which makes the table smaller. + * + * The first section of the table handles bytes with leading C + * The second section of the table handles bytes with leading D + * The third section of the table handles bytes with leading E + * The last section of the table handles bytes with leading F + * + * The values themselfs in the table are arranged so that when you + * left shift them by 6 to shift continuation characters into place, the + * new top bits tell you: + * + * 1 - if you keep going + * 2 - the range of valid values for the next byte */ static const uint32_t utf8_tab[] = { - 0xC0000002, 0xC0000003, 0xC0000004, 0xC0000005, 0xC0000006, 0xC0000007, - 0xC0000008, 0xC0000009, 0xC000000A, 0xC000000B, 0xC000000C, 0xC000000D, - 0xC000000E, 0xC000000F, 0xC0000010, 0xC0000011, 0xC0000012, 0xC0000013, - 0xC0000014, 0xC0000015, 0xC0000016, 0xC0000017, 0xC0000018, 0xC0000019, - 0xC000001A, 0xC000001B, 0xC000001C, 0xC000001D, 0xC000001E, 0xC000001F, - 0xB3000000, 0xC3000001, 0xC3000002, 0xC3000003, 0xC3000004, 0xC3000005, - 0xC3000006, 0xC3000007, 0xC3000008, 0xC3000009, 0xC300000A, 0xC300000B, - 0xC300000C, 0xD300000D, 0xC300000E, 0xC300000F, 0xBB0C0000, 0xC30C0001, - 0xC30C0002, 0xC30C0003, 0xD30C0004, 0x58257830, 0x202C, 0x3B031B01, - 0x30, 0x5, 0xFFFFFD1C, 0x7C, 0xFFFFFD5C, 0x4C, - 0xFFFFFE4C, 0xA4, 0xFFFFFE8C, 0xC4, 0xFFFFFEFC, 0x10C, - 0x14, 0x0, 0x527A01, 0x1107801, 0x8070C1B, 0x10070190, - 0x14, 0x1C, 0xFFFFFD08, 0x2A, 0x0, 0x0, - 0x14, 0x0, 0x527A01, 0x1107801, 0x8070C1B, 0x190, - 0x24, 0x1C, 0xFFFFFC98, 0x40, 0x46100E00, 0xF4A180E, - 0x8008770B, 0x3B1A3F00, 0x2224332A, 0x0, 0x1C, 0x44, - 0xFFFFFDA0, 0x3E, 0x100E4100, 0xD430286, 0x70C7906, 0x8, - 0x44, 0x64, 0xFFFFFDC0, 0x65, 0x100E4200, 0xE45028F, - 0x45038E18, 0x48D200E, 0x8C280E45, 0x300E4805, 0xE480686, 0x4D078338, - 0xE6C400E, 0x300E4138, 0x42280E41, 0xE42200E, 0x100E4218, 0x80E42, - 0x14, 0xAC, 0xFFFFFDE8, 0x2, 0x0, 0x0, - 0x0, 0x0, 0x4004D0, 0x0, 0x4004B0, 0x0, - 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, - 0xC, 0x0, 0x4003A8, 0x0, 0xD, 0x0, - 0x4005B4, 0x0, 0x19, 0x0, 0x6007E0, 0x0, - 0x1B, 0x0, 0x8, 0x0, 0x1A, 0x0, - 0x6007E8, 0x0, 0x1C, 0x0, 0x8, 0x0, - 0x6FFFFEF5, 0x0, 0x400260, 0x0, 0x5, 0x0, - 0x4002E0, 0x0, 0x6, 0x0, 0x400280, 0x0, - 0xA, 0x0, 0x3F, 0x0, 0xB, 0x0, - 0x18, 0x0, 0x15, 0x0, 0x0, 0x0, - 0x3, 0x0, 0x6009D0, 0x0, 0x2, 0x0, - 0x48, 0x0, 0x14, 0x0, 0x7, 0x0, - 0x17, 0x0, 0x400360, 0x0, 0x7, 0x0 + 0xC0000002, 0xC0000003, 0xC0000004, 0xC0000005, 0xC0000006, + 0xC0000007, 0xC0000008, 0xC0000009, 0xC000000A, 0xC000000B, + 0xC000000C, 0xC000000D, 0xC000000E, 0xC000000F, 0xC0000010, + 0xC0000011, 0xC0000012, 0xC0000013, 0xC0000014, 0xC0000015, + 0xC0000016, 0xC0000017, 0xC0000018, 0xC0000019, 0xC000001A, + 0xC000001B, 0xC000001C, 0xC000001D, 0xC000001E, 0xC000001F, + 0xB3000000, 0xC3000001, 0xC3000002, 0xC3000003, 0xC3000004, + 0xC3000005, 0xC3000006, 0xC3000007, 0xC3000008, 0xC3000009, + 0xC300000A, 0xC300000B, 0xC300000C, 0xD300000D, 0xC300000E, + 0xC300000F, 0xBB0C0000, 0xC30C0001, 0xC30C0002, 0xC30C0003, + 0xD30C0004 }; int utf8_from(char *s, utf8ch_t ch) {