X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fi18n.c;h=dca85db4f0ee48670a2519bd37bc68f27f58f536;hb=8c55ecac749f80d53a7ff807eee563a4a48b72dc;hp=1779afc4347ced85aea4b285d5906176c239f12e;hpb=23fd25fa0a2fb9d613f4f9445000e49cc3b83db1;p=pspp diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c index 1779afc434..dca85db4f0 100644 --- a/src/libpspp/i18n.c +++ b/src/libpspp/i18n.c @@ -748,6 +748,39 @@ utf8_strncasecmp (const char *a, size_t an, const char *b, size_t bn) return result; } + +static char * +utf8_casemap (const char *s, + uint8_t *(*f) (const uint8_t *, size_t, const char *, uninorm_t, + uint8_t *, size_t *)) +{ + char *result; + size_t size; + + result = CHAR_CAST (char *, + f (CHAR_CAST (const uint8_t *, s), strlen (s) + 1, + NULL, NULL, NULL, &size)); + if (result == NULL) + { + if (errno == ENOMEM) + xalloc_die (); + + result = xstrdup (s); + } + return result; +} + +char * +utf8_to_upper (const char *s) +{ + return utf8_casemap (s, u8_toupper); +} + +char * +utf8_to_lower (const char *s) +{ + return utf8_casemap (s, u8_tolower); +} bool get_encoding_info (struct encoding_info *e, const char *name)