Switch from ICU deprecated unorm_normalize to unorm2_normalize. (#569)

The new unorm2_normalize has been public API since ICU 4.4, while
the old unorm_normalize has been deprecated since ICU 56.

Now, beginning with ICU 60, unorm_normalize will also be annotated
U_DEPRECATED and trigger the compiler -Wdeprecated-declarations warning.
This commit is contained in:
Fredrik Roubert 2017-10-17 15:06:31 -07:00 committed by Behdad Esfahbod
parent b98adefbb9
commit 41b1984be9
1 changed files with 6 additions and 6 deletions

View File

@ -34,7 +34,7 @@
#include "hb-unicode-private.hh" #include "hb-unicode-private.hh"
#include <unicode/uchar.h> #include <unicode/uchar.h>
#include <unicode/unorm.h> #include <unicode/unorm2.h>
#include <unicode/ustring.h> #include <unicode/ustring.h>
#include <unicode/utf16.h> #include <unicode/utf16.h>
#include <unicode/uversion.h> #include <unicode/uversion.h>
@ -200,7 +200,7 @@ hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
if (err) return false; if (err) return false;
icu_err = U_ZERO_ERROR; icu_err = U_ZERO_ERROR;
len = unorm_normalize (utf16, len, UNORM_NFC, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); len = unorm2_normalize (unorm2_getNFCInstance (&icu_err), utf16, len, normalized, ARRAY_LENGTH (normalized), &icu_err);
if (U_FAILURE (icu_err)) if (U_FAILURE (icu_err))
return false; return false;
if (u_countChar32 (normalized, len) == 1) { if (u_countChar32 (normalized, len) == 1) {
@ -261,7 +261,7 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
if (err) return false; if (err) return false;
icu_err = U_ZERO_ERROR; icu_err = U_ZERO_ERROR;
len = unorm_normalize (utf16, len, UNORM_NFD, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); len = unorm2_normalize (unorm2_getNFDInstance (&icu_err), utf16, len, normalized, ARRAY_LENGTH (normalized), &icu_err);
if (U_FAILURE (icu_err)) if (U_FAILURE (icu_err))
return false; return false;
@ -281,7 +281,7 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
* the second part :-(. */ * the second part :-(. */
UChar recomposed[20]; UChar recomposed[20];
icu_err = U_ZERO_ERROR; icu_err = U_ZERO_ERROR;
unorm_normalize (normalized, len, UNORM_NFC, 0, recomposed, ARRAY_LENGTH (recomposed), &icu_err); unorm2_normalize (unorm2_getNFCInstance (&icu_err), normalized, len, recomposed, ARRAY_LENGTH (recomposed), &icu_err);
if (U_FAILURE (icu_err)) if (U_FAILURE (icu_err))
return false; return false;
hb_codepoint_t c; hb_codepoint_t c;
@ -297,7 +297,7 @@ hb_icu_unicode_decompose (hb_unicode_funcs_t *ufuncs HB_UNUSED,
U16_PREV_UNSAFE (normalized, len, *b); /* Changes len in-place. */ U16_PREV_UNSAFE (normalized, len, *b); /* Changes len in-place. */
UChar recomposed[18 * 2]; UChar recomposed[18 * 2];
icu_err = U_ZERO_ERROR; icu_err = U_ZERO_ERROR;
len = unorm_normalize (normalized, len, UNORM_NFC, 0, recomposed, ARRAY_LENGTH (recomposed), &icu_err); len = unorm2_normalize (unorm2_getNFCInstance (&icu_err), normalized, len, recomposed, ARRAY_LENGTH (recomposed), &icu_err);
if (U_FAILURE (icu_err)) if (U_FAILURE (icu_err))
return false; return false;
/* We expect that recomposed has exactly one character now. */ /* We expect that recomposed has exactly one character now. */
@ -331,7 +331,7 @@ hb_icu_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs HB_UNUSED,
/* Normalise the codepoint using NFKD mode. */ /* Normalise the codepoint using NFKD mode. */
icu_err = U_ZERO_ERROR; icu_err = U_ZERO_ERROR;
len = unorm_normalize (utf16, len, UNORM_NFKD, 0, normalized, ARRAY_LENGTH (normalized), &icu_err); len = unorm2_normalize (unorm2_getNFKDInstance (&icu_err), utf16, len, normalized, ARRAY_LENGTH (normalized), &icu_err);
if (icu_err) if (icu_err)
return 0; return 0;