Created
May 2, 2012 13:18
-
-
Save julp/2576477 to your computer and use it in GitHub Desktop.
Dump ICU UCollator rules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define icu_error(status, function) \ | |
fprintf(stderr, "ICU Error \"%s\" from " function "()\n", u_errorName(status)) | |
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) | |
#define USTRING_SIZE(array) ARRAY_SIZE(array) | |
#define USTRING_LENGTH(array) (USTRING_SIZE(array) - 1) | |
#include <unicode/ustdio.h> | |
#define u_printf(...) \ | |
do { \ | |
UFILE *ustdout = u_finit(stdout, NULL, NULL); \ | |
u_fprintf(ustdout, ## __VA_ARGS__); \ | |
} while (0); | |
/* ================================================== */ | |
#include <stdlib.h> | |
#include <unicode/ucol.h> | |
int main(void) | |
{ | |
UErrorCode status; | |
UCollator *ucol; | |
status = U_ZERO_ERROR; | |
ucol = ucol_open("fr_FR", &status); | |
//ucol_setAttribute(ucol, UCOL_NORMALIZATION_MODE, UCOL_ON, &status); | |
ucol_setStrength(ucol, UCOL_TERTIARY); | |
{ | |
UChar *rules; | |
int32_t rules_len, rules_size, ret; | |
UColRuleOption delta = UCOL_FULL_RULES; | |
// UColRuleOption delta = UCOL_TAILORING_ONLY; /* Locale rules only, *if* any */ | |
rules = NULL; | |
rules_size = 0; | |
rules_len = ucol_getRulesEx(ucol, delta, rules, rules_size); | |
printf("rules_len = %d\n", rules_len); | |
rules_size = rules_len + 1; | |
rules = calloc(rules_size, sizeof(*rules)); | |
ret = ucol_getRulesEx(ucol, delta, rules, rules_size); | |
u_printf("rules (%d) = (%d) >%S<\n", ret, rules_len, rules); | |
free(rules); | |
} | |
ucol_close(ucol); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment