MCPcopy Create free account
hub / github.com/JuliaStrings/utf8proc / utf8proc_decompose_char

Function utf8proc_decompose_char

utf8proc.c:452–538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450 (utf8proc_option_t)(options & ~(unsigned int)UTF8PROC_LUMP), last_boundclass)
451
452UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_decompose_char(utf8proc_int32_t uc, utf8proc_int32_t *dst, utf8proc_ssize_t bufsize, utf8proc_option_t options, int *last_boundclass) {
453 const utf8proc_property_t *property;
454 utf8proc_propval_t category;
455 utf8proc_int32_t hangul_sindex;
456 if (uc < 0 || uc >= 0x110000) return UTF8PROC_ERROR_NOTASSIGNED;
457 property = unsafe_get_property(uc);
458 category = property->category;
459 hangul_sindex = uc - UTF8PROC_HANGUL_SBASE;
460 if (options & (UTF8PROC_COMPOSE|UTF8PROC_DECOMPOSE)) {
461 if (hangul_sindex >= 0 && hangul_sindex < UTF8PROC_HANGUL_SCOUNT) {
462 utf8proc_int32_t hangul_tindex;
463 if (bufsize >= 1) {
464 dst[0] = UTF8PROC_HANGUL_LBASE +
465 hangul_sindex / UTF8PROC_HANGUL_NCOUNT;
466 if (bufsize >= 2) dst[1] = UTF8PROC_HANGUL_VBASE +
467 (hangul_sindex % UTF8PROC_HANGUL_NCOUNT) / UTF8PROC_HANGUL_TCOUNT;
468 }
469 hangul_tindex = hangul_sindex % UTF8PROC_HANGUL_TCOUNT;
470 if (!hangul_tindex) return 2;
471 if (bufsize >= 3) dst[2] = UTF8PROC_HANGUL_TBASE + hangul_tindex;
472 return 3;
473 }
474 }
475 if (options & UTF8PROC_REJECTNA) {
476 if (!category) return UTF8PROC_ERROR_NOTASSIGNED;
477 }
478 if (options & UTF8PROC_IGNORE) {
479 if (property->ignorable) return 0;
480 }
481 if (options & UTF8PROC_STRIPNA) {
482 if (!category) return 0;
483 }
484 if (options & UTF8PROC_LUMP) {
485 if (category == UTF8PROC_CATEGORY_ZS) utf8proc_decompose_lump(0x0020);
486 if (uc == 0x2018 || uc == 0x2019 || uc == 0x02BC || uc == 0x02C8)
487 utf8proc_decompose_lump(0x0027);
488 if (category == UTF8PROC_CATEGORY_PD || uc == 0x2212)
489 utf8proc_decompose_lump(0x002D);
490 if (uc == 0x2044 || uc == 0x2215) utf8proc_decompose_lump(0x002F);
491 if (uc == 0x2236) utf8proc_decompose_lump(0x003A);
492 if (uc == 0x2039 || uc == 0x2329 || uc == 0x3008)
493 utf8proc_decompose_lump(0x003C);
494 if (uc == 0x203A || uc == 0x232A || uc == 0x3009)
495 utf8proc_decompose_lump(0x003E);
496 if (uc == 0x2216) utf8proc_decompose_lump(0x005C);
497 if (uc == 0x02C4 || uc == 0x02C6 || uc == 0x2038 || uc == 0x2303)
498 utf8proc_decompose_lump(0x005E);
499 if (category == UTF8PROC_CATEGORY_PC || uc == 0x02CD)
500 utf8proc_decompose_lump(0x005F);
501 if (uc == 0x02CB) utf8proc_decompose_lump(0x0060);
502 if (uc == 0x2223) utf8proc_decompose_lump(0x007C);
503 if (uc == 0x223C) utf8proc_decompose_lump(0x007E);
504 if ((options & UTF8PROC_NLF2LS) && (options & UTF8PROC_NLF2PS)) {
505 if (category == UTF8PROC_CATEGORY_ZL ||
506 category == UTF8PROC_CATEGORY_ZP)
507 utf8proc_decompose_lump(0x000A);
508 }
509 }

Callers 3

mainFunction · 0.85

Calls 3

unsafe_get_propertyFunction · 0.85
grapheme_break_extendedFunction · 0.85

Tested by

no test coverage detected