normalizer2.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. *
  6. * Copyright (C) 2009-2016, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. *******************************************************************************
  10. * file name: normalizer2.cpp
  11. * encoding: UTF-8
  12. * tab size: 8 (not used)
  13. * indentation:4
  14. *
  15. * created on: 2009nov22
  16. * created by: Markus W. Scherer
  17. */
  18. #include "unicode/utypes.h"
  19. #if !UCONFIG_NO_NORMALIZATION
  20. #include "unicode/edits.h"
  21. #include "unicode/normalizer2.h"
  22. #include "unicode/stringoptions.h"
  23. #include "unicode/unistr.h"
  24. #include "unicode/unorm.h"
  25. #include "cstring.h"
  26. #include "mutex.h"
  27. #include "norm2allmodes.h"
  28. #include "normalizer2impl.h"
  29. #include "uassert.h"
  30. #include "ucln_cmn.h"
  31. using icu::Normalizer2Impl;
  32. #if NORM2_HARDCODE_NFC_DATA
  33. // NFC/NFD data machine-generated by gennorm2 --csource
  34. #define INCLUDED_FROM_NORMALIZER2_CPP
  35. #include "norm2_nfc_data.h"
  36. #endif
  37. U_NAMESPACE_BEGIN
  38. // Public API dispatch via Normalizer2 subclasses -------------------------- ***
  39. Normalizer2::~Normalizer2() {}
  40. void
  41. Normalizer2::normalizeUTF8(uint32_t /*options*/, StringPiece src, ByteSink &sink,
  42. Edits *edits, UErrorCode &errorCode) const {
  43. if (U_FAILURE(errorCode)) {
  44. return;
  45. }
  46. if (edits != nullptr) {
  47. errorCode = U_UNSUPPORTED_ERROR;
  48. return;
  49. }
  50. UnicodeString src16 = UnicodeString::fromUTF8(src);
  51. normalize(src16, errorCode).toUTF8(sink);
  52. }
  53. UBool
  54. Normalizer2::getRawDecomposition(UChar32, UnicodeString &) const {
  55. return false;
  56. }
  57. UChar32
  58. Normalizer2::composePair(UChar32, UChar32) const {
  59. return U_SENTINEL;
  60. }
  61. uint8_t
  62. Normalizer2::getCombiningClass(UChar32 /*c*/) const {
  63. return 0;
  64. }
  65. UBool
  66. Normalizer2::isNormalizedUTF8(StringPiece s, UErrorCode &errorCode) const {
  67. return U_SUCCESS(errorCode) && isNormalized(UnicodeString::fromUTF8(s), errorCode);
  68. }
  69. // Normalizer2 implementation for the old UNORM_NONE.
  70. class NoopNormalizer2 : public Normalizer2 {
  71. virtual ~NoopNormalizer2();
  72. virtual UnicodeString &
  73. normalize(const UnicodeString &src,
  74. UnicodeString &dest,
  75. UErrorCode &errorCode) const override {
  76. if(U_SUCCESS(errorCode)) {
  77. if(&dest!=&src) {
  78. dest=src;
  79. } else {
  80. errorCode=U_ILLEGAL_ARGUMENT_ERROR;
  81. }
  82. }
  83. return dest;
  84. }
  85. virtual void
  86. normalizeUTF8(uint32_t options, StringPiece src, ByteSink &sink,
  87. Edits *edits, UErrorCode &errorCode) const override {
  88. if(U_SUCCESS(errorCode)) {
  89. if (edits != nullptr) {
  90. if ((options & U_EDITS_NO_RESET) == 0) {
  91. edits->reset();
  92. }
  93. edits->addUnchanged(src.length());
  94. }
  95. if ((options & U_OMIT_UNCHANGED_TEXT) == 0) {
  96. sink.Append(src.data(), src.length());
  97. }
  98. sink.Flush();
  99. }
  100. }
  101. virtual UnicodeString &
  102. normalizeSecondAndAppend(UnicodeString &first,
  103. const UnicodeString &second,
  104. UErrorCode &errorCode) const override {
  105. if(U_SUCCESS(errorCode)) {
  106. if(&first!=&second) {
  107. first.append(second);
  108. } else {
  109. errorCode=U_ILLEGAL_ARGUMENT_ERROR;
  110. }
  111. }
  112. return first;
  113. }
  114. virtual UnicodeString &
  115. append(UnicodeString &first,
  116. const UnicodeString &second,
  117. UErrorCode &errorCode) const override {
  118. if(U_SUCCESS(errorCode)) {
  119. if(&first!=&second) {
  120. first.append(second);
  121. } else {
  122. errorCode=U_ILLEGAL_ARGUMENT_ERROR;
  123. }
  124. }
  125. return first;
  126. }
  127. virtual UBool
  128. getDecomposition(UChar32, UnicodeString &) const override {
  129. return false;
  130. }
  131. // No need to override the default getRawDecomposition().
  132. virtual UBool
  133. isNormalized(const UnicodeString &, UErrorCode &errorCode) const override {
  134. return U_SUCCESS(errorCode);
  135. }
  136. virtual UBool
  137. isNormalizedUTF8(StringPiece, UErrorCode &errorCode) const override {
  138. return U_SUCCESS(errorCode);
  139. }
  140. virtual UNormalizationCheckResult
  141. quickCheck(const UnicodeString &, UErrorCode &) const override {
  142. return UNORM_YES;
  143. }
  144. virtual int32_t
  145. spanQuickCheckYes(const UnicodeString &s, UErrorCode &) const override {
  146. return s.length();
  147. }
  148. virtual UBool hasBoundaryBefore(UChar32) const override { return true; }
  149. virtual UBool hasBoundaryAfter(UChar32) const override { return true; }
  150. virtual UBool isInert(UChar32) const override { return true; }
  151. };
  152. NoopNormalizer2::~NoopNormalizer2() {}
  153. Normalizer2WithImpl::~Normalizer2WithImpl() {}
  154. DecomposeNormalizer2::~DecomposeNormalizer2() {}
  155. ComposeNormalizer2::~ComposeNormalizer2() {}
  156. FCDNormalizer2::~FCDNormalizer2() {}
  157. // instance cache ---------------------------------------------------------- ***
  158. U_CDECL_BEGIN
  159. static UBool U_CALLCONV uprv_normalizer2_cleanup();
  160. U_CDECL_END
  161. static Normalizer2 *noopSingleton;
  162. static icu::UInitOnce noopInitOnce {};
  163. static void U_CALLCONV initNoopSingleton(UErrorCode &errorCode) {
  164. if(U_FAILURE(errorCode)) {
  165. return;
  166. }
  167. noopSingleton=new NoopNormalizer2;
  168. if(noopSingleton==nullptr) {
  169. errorCode=U_MEMORY_ALLOCATION_ERROR;
  170. return;
  171. }
  172. ucln_common_registerCleanup(UCLN_COMMON_NORMALIZER2, uprv_normalizer2_cleanup);
  173. }
  174. const Normalizer2 *Normalizer2Factory::getNoopInstance(UErrorCode &errorCode) {
  175. if(U_FAILURE(errorCode)) { return nullptr; }
  176. umtx_initOnce(noopInitOnce, &initNoopSingleton, errorCode);
  177. return noopSingleton;
  178. }
  179. const Normalizer2Impl *
  180. Normalizer2Factory::getImpl(const Normalizer2 *norm2) {
  181. return &((Normalizer2WithImpl *)norm2)->impl;
  182. }
  183. Norm2AllModes::~Norm2AllModes() {
  184. delete impl;
  185. }
  186. Norm2AllModes *
  187. Norm2AllModes::createInstance(Normalizer2Impl *impl, UErrorCode &errorCode) {
  188. if(U_FAILURE(errorCode)) {
  189. delete impl;
  190. return nullptr;
  191. }
  192. Norm2AllModes *allModes=new Norm2AllModes(impl);
  193. if(allModes==nullptr) {
  194. errorCode=U_MEMORY_ALLOCATION_ERROR;
  195. delete impl;
  196. return nullptr;
  197. }
  198. return allModes;
  199. }
  200. #if NORM2_HARDCODE_NFC_DATA
  201. Norm2AllModes *
  202. Norm2AllModes::createNFCInstance(UErrorCode &errorCode) {
  203. if(U_FAILURE(errorCode)) {
  204. return nullptr;
  205. }
  206. Normalizer2Impl *impl=new Normalizer2Impl;
  207. if(impl==nullptr) {
  208. errorCode=U_MEMORY_ALLOCATION_ERROR;
  209. return nullptr;
  210. }
  211. impl->init(norm2_nfc_data_indexes, &norm2_nfc_data_trie,
  212. norm2_nfc_data_extraData, norm2_nfc_data_smallFCD);
  213. return createInstance(impl, errorCode);
  214. }
  215. static Norm2AllModes *nfcSingleton;
  216. static icu::UInitOnce nfcInitOnce {};
  217. static void U_CALLCONV initNFCSingleton(UErrorCode &errorCode) {
  218. nfcSingleton=Norm2AllModes::createNFCInstance(errorCode);
  219. ucln_common_registerCleanup(UCLN_COMMON_NORMALIZER2, uprv_normalizer2_cleanup);
  220. }
  221. const Norm2AllModes *
  222. Norm2AllModes::getNFCInstance(UErrorCode &errorCode) {
  223. if(U_FAILURE(errorCode)) { return nullptr; }
  224. umtx_initOnce(nfcInitOnce, &initNFCSingleton, errorCode);
  225. return nfcSingleton;
  226. }
  227. const Normalizer2 *
  228. Normalizer2::getNFCInstance(UErrorCode &errorCode) {
  229. const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
  230. return allModes!=nullptr ? &allModes->comp : nullptr;
  231. }
  232. const Normalizer2 *
  233. Normalizer2::getNFDInstance(UErrorCode &errorCode) {
  234. const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
  235. return allModes!=nullptr ? &allModes->decomp : nullptr;
  236. }
  237. const Normalizer2 *Normalizer2Factory::getFCDInstance(UErrorCode &errorCode) {
  238. const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
  239. return allModes!=nullptr ? &allModes->fcd : nullptr;
  240. }
  241. const Normalizer2 *Normalizer2Factory::getFCCInstance(UErrorCode &errorCode) {
  242. const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
  243. return allModes!=nullptr ? &allModes->fcc : nullptr;
  244. }
  245. const Normalizer2Impl *
  246. Normalizer2Factory::getNFCImpl(UErrorCode &errorCode) {
  247. const Norm2AllModes *allModes=Norm2AllModes::getNFCInstance(errorCode);
  248. return allModes!=nullptr ? allModes->impl : nullptr;
  249. }
  250. #endif // NORM2_HARDCODE_NFC_DATA
  251. U_CDECL_BEGIN
  252. static UBool U_CALLCONV uprv_normalizer2_cleanup() {
  253. delete noopSingleton;
  254. noopSingleton = nullptr;
  255. noopInitOnce.reset();
  256. #if NORM2_HARDCODE_NFC_DATA
  257. delete nfcSingleton;
  258. nfcSingleton = nullptr;
  259. nfcInitOnce.reset();
  260. #endif
  261. return true;
  262. }
  263. U_CDECL_END
  264. U_NAMESPACE_END
  265. // C API ------------------------------------------------------------------- ***
  266. U_NAMESPACE_USE
  267. U_CAPI const UNormalizer2 * U_EXPORT2
  268. unorm2_getNFCInstance(UErrorCode *pErrorCode) {
  269. return (const UNormalizer2 *)Normalizer2::getNFCInstance(*pErrorCode);
  270. }
  271. U_CAPI const UNormalizer2 * U_EXPORT2
  272. unorm2_getNFDInstance(UErrorCode *pErrorCode) {
  273. return (const UNormalizer2 *)Normalizer2::getNFDInstance(*pErrorCode);
  274. }
  275. U_CAPI void U_EXPORT2
  276. unorm2_close(UNormalizer2 *norm2) {
  277. delete (Normalizer2 *)norm2;
  278. }
  279. U_CAPI int32_t U_EXPORT2
  280. unorm2_normalize(const UNormalizer2 *norm2,
  281. const char16_t *src, int32_t length,
  282. char16_t *dest, int32_t capacity,
  283. UErrorCode *pErrorCode) {
  284. if(U_FAILURE(*pErrorCode)) {
  285. return 0;
  286. }
  287. if( (src==nullptr ? length!=0 : length<-1) ||
  288. (dest==nullptr ? capacity!=0 : capacity<0) ||
  289. (src==dest && src!=nullptr)
  290. ) {
  291. *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
  292. return 0;
  293. }
  294. UnicodeString destString(dest, 0, capacity);
  295. // length==0: Nothing to do, and n2wi->normalize(nullptr, nullptr, buffer, ...) would crash.
  296. if(length!=0) {
  297. const Normalizer2 *n2=(const Normalizer2 *)norm2;
  298. const Normalizer2WithImpl *n2wi=dynamic_cast<const Normalizer2WithImpl *>(n2);
  299. if(n2wi!=nullptr) {
  300. // Avoid duplicate argument checking and support NUL-terminated src.
  301. ReorderingBuffer buffer(n2wi->impl, destString);
  302. if(buffer.init(length, *pErrorCode)) {
  303. n2wi->normalize(src, length>=0 ? src+length : nullptr, buffer, *pErrorCode);
  304. }
  305. } else {
  306. UnicodeString srcString(length<0, src, length);
  307. n2->normalize(srcString, destString, *pErrorCode);
  308. }
  309. }
  310. return destString.extract(dest, capacity, *pErrorCode);
  311. }
  312. static int32_t
  313. normalizeSecondAndAppend(const UNormalizer2 *norm2,
  314. char16_t *first, int32_t firstLength, int32_t firstCapacity,
  315. const char16_t *second, int32_t secondLength,
  316. UBool doNormalize,
  317. UErrorCode *pErrorCode) {
  318. if(U_FAILURE(*pErrorCode)) {
  319. return 0;
  320. }
  321. if( (second==nullptr ? secondLength!=0 : secondLength<-1) ||
  322. (first==nullptr ? (firstCapacity!=0 || firstLength!=0) :
  323. (firstCapacity<0 || firstLength<-1)) ||
  324. (first==second && first!=nullptr)
  325. ) {
  326. *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
  327. return 0;
  328. }
  329. UnicodeString firstString(first, firstLength, firstCapacity);
  330. firstLength=firstString.length(); // In case it was -1.
  331. // secondLength==0: Nothing to do, and n2wi->normalizeAndAppend(nullptr, nullptr, buffer, ...) would crash.
  332. if(secondLength!=0) {
  333. const Normalizer2* n2 = reinterpret_cast<const Normalizer2*>(norm2);
  334. const Normalizer2WithImpl* n2wi = dynamic_cast<const Normalizer2WithImpl*>(n2);
  335. if(n2wi!=nullptr) {
  336. // Avoid duplicate argument checking and support NUL-terminated src.
  337. UnicodeString safeMiddle;
  338. {
  339. ReorderingBuffer buffer(n2wi->impl, firstString);
  340. if(buffer.init(firstLength+secondLength+1, *pErrorCode)) { // destCapacity>=-1
  341. n2wi->normalizeAndAppend(second, secondLength>=0 ? second+secondLength : nullptr,
  342. doNormalize, safeMiddle, buffer, *pErrorCode);
  343. }
  344. } // The ReorderingBuffer destructor finalizes firstString.
  345. if(U_FAILURE(*pErrorCode) || firstString.length()>firstCapacity) {
  346. // Restore the modified suffix of the first string.
  347. // This does not restore first[] array contents between firstLength and firstCapacity.
  348. // (That might be uninitialized memory, as far as we know.)
  349. if(first!=nullptr) { /* don't dereference nullptr */
  350. safeMiddle.extract(0, 0x7fffffff, first+firstLength-safeMiddle.length());
  351. if(firstLength<firstCapacity) {
  352. first[firstLength]=0; // NUL-terminate in case it was originally.
  353. }
  354. }
  355. }
  356. } else {
  357. UnicodeString secondString(secondLength<0, second, secondLength);
  358. if(doNormalize) {
  359. n2->normalizeSecondAndAppend(firstString, secondString, *pErrorCode);
  360. } else {
  361. n2->append(firstString, secondString, *pErrorCode);
  362. }
  363. }
  364. }
  365. return firstString.extract(first, firstCapacity, *pErrorCode);
  366. }
  367. U_CAPI int32_t U_EXPORT2
  368. unorm2_normalizeSecondAndAppend(const UNormalizer2 *norm2,
  369. char16_t *first, int32_t firstLength, int32_t firstCapacity,
  370. const char16_t *second, int32_t secondLength,
  371. UErrorCode *pErrorCode) {
  372. return normalizeSecondAndAppend(norm2,
  373. first, firstLength, firstCapacity,
  374. second, secondLength,
  375. true, pErrorCode);
  376. }
  377. U_CAPI int32_t U_EXPORT2
  378. unorm2_append(const UNormalizer2 *norm2,
  379. char16_t *first, int32_t firstLength, int32_t firstCapacity,
  380. const char16_t *second, int32_t secondLength,
  381. UErrorCode *pErrorCode) {
  382. return normalizeSecondAndAppend(norm2,
  383. first, firstLength, firstCapacity,
  384. second, secondLength,
  385. false, pErrorCode);
  386. }
  387. U_CAPI int32_t U_EXPORT2
  388. unorm2_getDecomposition(const UNormalizer2 *norm2,
  389. UChar32 c, char16_t *decomposition, int32_t capacity,
  390. UErrorCode *pErrorCode) {
  391. if(U_FAILURE(*pErrorCode)) {
  392. return 0;
  393. }
  394. if(decomposition==nullptr ? capacity!=0 : capacity<0) {
  395. *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
  396. return 0;
  397. }
  398. UnicodeString destString(decomposition, 0, capacity);
  399. if(reinterpret_cast<const Normalizer2 *>(norm2)->getDecomposition(c, destString)) {
  400. return destString.extract(decomposition, capacity, *pErrorCode);
  401. } else {
  402. return -1;
  403. }
  404. }
  405. U_CAPI int32_t U_EXPORT2
  406. unorm2_getRawDecomposition(const UNormalizer2 *norm2,
  407. UChar32 c, char16_t *decomposition, int32_t capacity,
  408. UErrorCode *pErrorCode) {
  409. if(U_FAILURE(*pErrorCode)) {
  410. return 0;
  411. }
  412. if(decomposition==nullptr ? capacity!=0 : capacity<0) {
  413. *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
  414. return 0;
  415. }
  416. UnicodeString destString(decomposition, 0, capacity);
  417. if(reinterpret_cast<const Normalizer2 *>(norm2)->getRawDecomposition(c, destString)) {
  418. return destString.extract(decomposition, capacity, *pErrorCode);
  419. } else {
  420. return -1;
  421. }
  422. }
  423. U_CAPI UChar32 U_EXPORT2
  424. unorm2_composePair(const UNormalizer2 *norm2, UChar32 a, UChar32 b) {
  425. return reinterpret_cast<const Normalizer2 *>(norm2)->composePair(a, b);
  426. }
  427. U_CAPI uint8_t U_EXPORT2
  428. unorm2_getCombiningClass(const UNormalizer2 *norm2, UChar32 c) {
  429. return reinterpret_cast<const Normalizer2 *>(norm2)->getCombiningClass(c);
  430. }
  431. U_CAPI UBool U_EXPORT2
  432. unorm2_isNormalized(const UNormalizer2 *norm2,
  433. const char16_t *s, int32_t length,
  434. UErrorCode *pErrorCode) {
  435. if(U_FAILURE(*pErrorCode)) {
  436. return 0;
  437. }
  438. if((s==nullptr && length!=0) || length<-1) {
  439. *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
  440. return 0;
  441. }
  442. UnicodeString sString(length<0, s, length);
  443. return ((const Normalizer2 *)norm2)->isNormalized(sString, *pErrorCode);
  444. }
  445. U_CAPI UNormalizationCheckResult U_EXPORT2
  446. unorm2_quickCheck(const UNormalizer2 *norm2,
  447. const char16_t *s, int32_t length,
  448. UErrorCode *pErrorCode) {
  449. if(U_FAILURE(*pErrorCode)) {
  450. return UNORM_NO;
  451. }
  452. if((s==nullptr && length!=0) || length<-1) {
  453. *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
  454. return UNORM_NO;
  455. }
  456. UnicodeString sString(length<0, s, length);
  457. return ((const Normalizer2 *)norm2)->quickCheck(sString, *pErrorCode);
  458. }
  459. U_CAPI int32_t U_EXPORT2
  460. unorm2_spanQuickCheckYes(const UNormalizer2 *norm2,
  461. const char16_t *s, int32_t length,
  462. UErrorCode *pErrorCode) {
  463. if(U_FAILURE(*pErrorCode)) {
  464. return 0;
  465. }
  466. if((s==nullptr && length!=0) || length<-1) {
  467. *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
  468. return 0;
  469. }
  470. UnicodeString sString(length<0, s, length);
  471. return ((const Normalizer2 *)norm2)->spanQuickCheckYes(sString, *pErrorCode);
  472. }
  473. U_CAPI UBool U_EXPORT2
  474. unorm2_hasBoundaryBefore(const UNormalizer2 *norm2, UChar32 c) {
  475. return ((const Normalizer2 *)norm2)->hasBoundaryBefore(c);
  476. }
  477. U_CAPI UBool U_EXPORT2
  478. unorm2_hasBoundaryAfter(const UNormalizer2 *norm2, UChar32 c) {
  479. return ((const Normalizer2 *)norm2)->hasBoundaryAfter(c);
  480. }
  481. U_CAPI UBool U_EXPORT2
  482. unorm2_isInert(const UNormalizer2 *norm2, UChar32 c) {
  483. return ((const Normalizer2 *)norm2)->isInert(c);
  484. }
  485. // Some properties APIs ---------------------------------------------------- ***
  486. U_CAPI uint8_t U_EXPORT2
  487. u_getCombiningClass(UChar32 c) {
  488. UErrorCode errorCode=U_ZERO_ERROR;
  489. const Normalizer2 *nfd=Normalizer2::getNFDInstance(errorCode);
  490. if(U_SUCCESS(errorCode)) {
  491. return nfd->getCombiningClass(c);
  492. } else {
  493. return 0;
  494. }
  495. }
  496. U_CFUNC uint16_t
  497. unorm_getFCD16(UChar32 c) {
  498. UErrorCode errorCode=U_ZERO_ERROR;
  499. const Normalizer2Impl *impl=Normalizer2Factory::getNFCImpl(errorCode);
  500. if(U_SUCCESS(errorCode)) {
  501. return impl->getFCD16(c);
  502. } else {
  503. return 0;
  504. }
  505. }
  506. #endif // !UCONFIG_NO_NORMALIZATION