Skip to content

Instantly share code, notes, and snippets.

@nwellnhof

nwellnhof/fc_nfkc.c

Created Nov 17, 2011
Embed
What would you like to do?
#include <stdio.h>
#include <stdlib.h>
#include "utf8proc.h"
static const int32_t codepoints[] = {
0x037A,
0x03D2,
0x03D3,
0x03D4,
0x03F2,
0x03F9,
0x1D2C,
0x1D2D,
0x1D2E,
0x1D30,
0x1D31,
0x1D32,
0x1D33,
0x1D34,
0x1D35,
0x1D36,
0x1D37,
0x1D38,
0x1D39,
0x1D3A,
0x1D3C,
0x1D3D,
0x1D3E,
0x1D3F,
0x1D40,
0x1D41,
0x1D42,
0x20A8,
0x2102,
0x2103,
0x2107,
0x2109,
0x210B,
0x210C,
0x210D,
0x2110,
0x2111,
0x2112,
0x2115,
0x2116,
0x2119,
0x211A,
0x211B,
0x211C,
0x211D,
0x2120,
0x2121,
0x2122,
0x2124,
0x2128,
0x212C,
0x212D,
0x2130,
0x2131,
0x2133,
0x213B,
0x213E,
0x213F,
0x2145,
0x3250,
0x32CC,
0x32CE,
0x32CF,
0x3371,
0x3373,
0x3375,
0x337A,
0x3380,
0x3381,
0x3382,
0x3383,
0x3384,
0x3385,
0x3386,
0x3387,
0x338A,
0x338B,
0x338C,
0x3390,
0x3391,
0x3392,
0x3393,
0x3394,
0x33A9,
0x33AA,
0x33AB,
0x33AC,
0x33B4,
0x33B5,
0x33B6,
0x33B7,
0x33B8,
0x33B9,
0x33BA,
0x33BB,
0x33BC,
0x33BD,
0x33BE,
0x33BF,
0x33C0,
0x33C1,
0x33C3,
0x33C6,
0x33C7,
0x33C8,
0x33C9,
0x33CB,
0x33CD,
0x33CE,
0x33D7,
0x33D9,
0x33DA,
0x33DC,
0x33DD,
0x33DE,
0x33DF,
0x1D400,
0x1D401,
0x1D402,
0x1D403,
0x1D404,
0x1D405,
0x1D406,
0x1D407,
0x1D408,
0x1D409,
0x1D40A,
0x1D40B,
0x1D40C,
0x1D40D,
0x1D40E,
0x1D40F,
0x1D410,
0x1D411,
0x1D412,
0x1D413,
0x1D414,
0x1D415,
0x1D416,
0x1D417,
0x1D418,
0x1D419,
0x1D434,
0x1D435,
0x1D436,
0x1D437,
0x1D438,
0x1D439,
0x1D43A,
0x1D43B,
0x1D43C,
0x1D43D,
0x1D43E,
0x1D43F,
0x1D440,
0x1D441,
0x1D442,
0x1D443,
0x1D444,
0x1D445,
0x1D446,
0x1D447,
0x1D448,
0x1D449,
0x1D44A,
0x1D44B,
0x1D44C,
0x1D44D,
0x1D468,
0x1D469,
0x1D46A,
0x1D46B,
0x1D46C,
0x1D46D,
0x1D46E,
0x1D46F,
0x1D470,
0x1D471,
0x1D472,
0x1D473,
0x1D474,
0x1D475,
0x1D476,
0x1D477,
0x1D478,
0x1D479,
0x1D47A,
0x1D47B,
0x1D47C,
0x1D47D,
0x1D47E,
0x1D47F,
0x1D480,
0x1D481,
0x1D49C,
0x1D49E,
0x1D49F,
0x1D4A2,
0x1D4A5,
0x1D4A6,
0x1D4A9,
0x1D4AA,
0x1D4AB,
0x1D4AC,
0x1D4AE,
0x1D4AF,
0x1D4B0,
0x1D4B1,
0x1D4B2,
0x1D4B3,
0x1D4B4,
0x1D4B5,
0x1D4D0,
0x1D4D1,
0x1D4D2,
0x1D4D3,
0x1D4D4,
0x1D4D5,
0x1D4D6,
0x1D4D7,
0x1D4D8,
0x1D4D9,
0x1D4DA,
0x1D4DB,
0x1D4DC,
0x1D4DD,
0x1D4DE,
0x1D4DF,
0x1D4E0,
0x1D4E1,
0x1D4E2,
0x1D4E3,
0x1D4E4,
0x1D4E5,
0x1D4E6,
0x1D4E7,
0x1D4E8,
0x1D4E9,
0x1D504,
0x1D505,
0x1D507,
0x1D508,
0x1D509,
0x1D50A,
0x1D50D,
0x1D50E,
0x1D50F,
0x1D510,
0x1D511,
0x1D512,
0x1D513,
0x1D514,
0x1D516,
0x1D517,
0x1D518,
0x1D519,
0x1D51A,
0x1D51B,
0x1D51C,
0x1D538,
0x1D539,
0x1D53B,
0x1D53C,
0x1D53D,
0x1D53E,
0x1D540,
0x1D541,
0x1D542,
0x1D543,
0x1D544,
0x1D546,
0x1D54A,
0x1D54B,
0x1D54C,
0x1D54D,
0x1D54E,
0x1D54F,
0x1D550,
0x1D56C,
0x1D56D,
0x1D56E,
0x1D56F,
0x1D570,
0x1D571,
0x1D572,
0x1D573,
0x1D574,
0x1D575,
0x1D576,
0x1D577,
0x1D578,
0x1D579,
0x1D57A,
0x1D57B,
0x1D57C,
0x1D57D,
0x1D57E,
0x1D57F,
0x1D580,
0x1D581,
0x1D582,
0x1D583,
0x1D584,
0x1D585,
0x1D5A0,
0x1D5A1,
0x1D5A2,
0x1D5A3,
0x1D5A4,
0x1D5A5,
0x1D5A6,
0x1D5A7,
0x1D5A8,
0x1D5A9,
0x1D5AA,
0x1D5AB,
0x1D5AC,
0x1D5AD,
0x1D5AE,
0x1D5AF,
0x1D5B0,
0x1D5B1,
0x1D5B2,
0x1D5B3,
0x1D5B4,
0x1D5B5,
0x1D5B6,
0x1D5B7,
0x1D5B8,
0x1D5B9,
0x1D5D4,
0x1D5D5,
0x1D5D6,
0x1D5D7,
0x1D5D8,
0x1D5D9,
0x1D5DA,
0x1D5DB,
0x1D5DC,
0x1D5DD,
0x1D5DE,
0x1D5DF,
0x1D5E0,
0x1D5E1,
0x1D5E2,
0x1D5E3,
0x1D5E4,
0x1D5E5,
0x1D5E6,
0x1D5E7,
0x1D5E8,
0x1D5E9,
0x1D5EA,
0x1D5EB,
0x1D5EC,
0x1D5ED,
0x1D608,
0x1D609,
0x1D60A,
0x1D60B,
0x1D60C,
0x1D60D,
0x1D60E,
0x1D60F,
0x1D610,
0x1D611,
0x1D612,
0x1D613,
0x1D614,
0x1D615,
0x1D616,
0x1D617,
0x1D618,
0x1D619,
0x1D61A,
0x1D61B,
0x1D61C,
0x1D61D,
0x1D61E,
0x1D61F,
0x1D620,
0x1D621,
0x1D63C,
0x1D63D,
0x1D63E,
0x1D63F,
0x1D640,
0x1D641,
0x1D642,
0x1D643,
0x1D644,
0x1D645,
0x1D646,
0x1D647,
0x1D648,
0x1D649,
0x1D64A,
0x1D64B,
0x1D64C,
0x1D64D,
0x1D64E,
0x1D64F,
0x1D650,
0x1D651,
0x1D652,
0x1D653,
0x1D654,
0x1D655,
0x1D670,
0x1D671,
0x1D672,
0x1D673,
0x1D674,
0x1D675,
0x1D676,
0x1D677,
0x1D678,
0x1D679,
0x1D67A,
0x1D67B,
0x1D67C,
0x1D67D,
0x1D67E,
0x1D67F,
0x1D680,
0x1D681,
0x1D682,
0x1D683,
0x1D684,
0x1D685,
0x1D686,
0x1D687,
0x1D688,
0x1D689,
0x1D6A8,
0x1D6A9,
0x1D6AA,
0x1D6AB,
0x1D6AC,
0x1D6AD,
0x1D6AE,
0x1D6AF,
0x1D6B0,
0x1D6B1,
0x1D6B2,
0x1D6B3,
0x1D6B4,
0x1D6B5,
0x1D6B6,
0x1D6B7,
0x1D6B8,
0x1D6B9,
0x1D6BA,
0x1D6BB,
0x1D6BC,
0x1D6BD,
0x1D6BE,
0x1D6BF,
0x1D6C0,
0x1D6D3,
0x1D6E2,
0x1D6E3,
0x1D6E4,
0x1D6E5,
0x1D6E6,
0x1D6E7,
0x1D6E8,
0x1D6E9,
0x1D6EA,
0x1D6EB,
0x1D6EC,
0x1D6ED,
0x1D6EE,
0x1D6EF,
0x1D6F0,
0x1D6F1,
0x1D6F2,
0x1D6F3,
0x1D6F4,
0x1D6F5,
0x1D6F6,
0x1D6F7,
0x1D6F8,
0x1D6F9,
0x1D6FA,
0x1D70D,
0x1D71C,
0x1D71D,
0x1D71E,
0x1D71F,
0x1D720,
0x1D721,
0x1D722,
0x1D723,
0x1D724,
0x1D725,
0x1D726,
0x1D727,
0x1D728,
0x1D729,
0x1D72A,
0x1D72B,
0x1D72C,
0x1D72D,
0x1D72E,
0x1D72F,
0x1D730,
0x1D731,
0x1D732,
0x1D733,
0x1D734,
0x1D747,
0x1D756,
0x1D757,
0x1D758,
0x1D759,
0x1D75A,
0x1D75B,
0x1D75C,
0x1D75D,
0x1D75E,
0x1D75F,
0x1D760,
0x1D761,
0x1D762,
0x1D763,
0x1D764,
0x1D765,
0x1D766,
0x1D767,
0x1D768,
0x1D769,
0x1D76A,
0x1D76B,
0x1D76C,
0x1D76D,
0x1D76E,
0x1D781,
0x1D790,
0x1D791,
0x1D792,
0x1D793,
0x1D794,
0x1D795,
0x1D796,
0x1D797,
0x1D798,
0x1D799,
0x1D79A,
0x1D79B,
0x1D79C,
0x1D79D,
0x1D79E,
0x1D79F,
0x1D7A0,
0x1D7A1,
0x1D7A2,
0x1D7A3,
0x1D7A4,
0x1D7A5,
0x1D7A6,
0x1D7A7,
0x1D7A8,
0x1D7BB,
0x1D7CA
};
int main()
{
uint8_t src[5];
uint8_t *dst;
uint8_t *p;
int32_t c;
ssize_t len;
int i, printed;
for (i = 0; i < sizeof(codepoints) / sizeof(codepoints[0]); ++i) {
len = utf8proc_encode_char(codepoints[i], src);
utf8proc_map(src, len, &dst,
UTF8PROC_STABLE |
UTF8PROC_COMPOSE |
UTF8PROC_COMPAT |
UTF8PROC_CASEFOLD);
printed = printf("%04X", codepoints[i]);
while (printed++ < 6) {
printf(" ");
}
printed = printf("; FC_NFKC;");
len = utf8proc_iterate(dst, -1, &c);
for (p = dst + len; len > 0 && c; p += len) {
printf(" %04X", c);
len = utf8proc_iterate(p, -1, &c);
}
printf("\n");
free(dst);
}
return EXIT_SUCCESS;
}
@rstackhouse

This comment has been minimized.

Copy link

@rstackhouse rstackhouse commented Oct 7, 2015

What is this demonstrating?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment