diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-10-30 18:15:48 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-10-30 18:15:48 +0000 |
commit | afa714da4ed5de15331a694b25a228e4e4426c18 (patch) | |
tree | 35669eea3b84448122138b019f4268b0959f665e /src/util/strings.c | |
parent | df64ed90529f6370a15bdb548f16b1948420c828 (diff) | |
download | gnunet-afa714da4ed5de15331a694b25a228e4e4426c18.tar.gz gnunet-afa714da4ed5de15331a694b25a228e4e4426c18.zip |
-simplify utf8_tolower/upper APIs
Diffstat (limited to 'src/util/strings.c')
-rw-r--r-- | src/util/strings.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/util/strings.c b/src/util/strings.c index 00c0cf0e1..d5c752fe1 100644 --- a/src/util/strings.c +++ b/src/util/strings.c | |||
@@ -492,44 +492,46 @@ GNUNET_STRINGS_from_utf8 (const char *input, | |||
492 | 492 | ||
493 | 493 | ||
494 | /** | 494 | /** |
495 | * Convert the utf-8 input string to lowercase | 495 | * Convert the utf-8 input string to lowercase. |
496 | * Output needs to be allocated appropriately | 496 | * Output needs to be allocated appropriately. |
497 | * | 497 | * |
498 | * @param input input string | 498 | * @param input input string |
499 | * @param output output buffer | 499 | * @param output output buffer |
500 | */ | 500 | */ |
501 | void | 501 | void |
502 | GNUNET_STRINGS_utf8_tolower(const char* input, char** output) | 502 | GNUNET_STRINGS_utf8_tolower (const char *input, |
503 | char *output) | ||
503 | { | 504 | { |
504 | uint8_t *tmp_in; | 505 | uint8_t *tmp_in; |
505 | size_t len; | 506 | size_t len; |
506 | 507 | ||
507 | tmp_in = u8_tolower ((uint8_t*)input, strlen ((char *) input), | 508 | tmp_in = u8_tolower ((uint8_t*)input, strlen ((char *) input), |
508 | NULL, UNINORM_NFD, NULL, &len); | 509 | NULL, UNINORM_NFD, NULL, &len); |
509 | memcpy(*output, tmp_in, len); | 510 | memcpy(output, tmp_in, len); |
510 | (*output)[len] = '\0'; | 511 | output[len] = '\0'; |
511 | free(tmp_in); | 512 | free(tmp_in); |
512 | } | 513 | } |
513 | 514 | ||
514 | 515 | ||
515 | /** | 516 | /** |
516 | * Convert the utf-8 input string to uppercase | 517 | * Convert the utf-8 input string to uppercase. |
517 | * Output needs to be allocated appropriately | 518 | * Output needs to be allocated appropriately. |
518 | * | 519 | * |
519 | * @param input input string | 520 | * @param input input string |
520 | * @param output output buffer | 521 | * @param output output buffer |
521 | */ | 522 | */ |
522 | void | 523 | void |
523 | GNUNET_STRINGS_utf8_toupper(const char* input, char** output) | 524 | GNUNET_STRINGS_utf8_toupper(const char *input, |
525 | char *output) | ||
524 | { | 526 | { |
525 | uint8_t *tmp_in; | 527 | uint8_t *tmp_in; |
526 | size_t len; | 528 | size_t len; |
527 | 529 | ||
528 | tmp_in = u8_toupper ((uint8_t*)input, strlen ((char *) input), | 530 | tmp_in = u8_toupper ((uint8_t*)input, strlen ((char *) input), |
529 | NULL, UNINORM_NFD, NULL, &len); | 531 | NULL, UNINORM_NFD, NULL, &len); |
530 | memcpy(*output, tmp_in, len); | 532 | memcpy (output, tmp_in, len); |
531 | (*output)[len] = '\0'; | 533 | output[len] = '\0'; |
532 | free(tmp_in); | 534 | free (tmp_in); |
533 | } | 535 | } |
534 | 536 | ||
535 | 537 | ||