// Fancy unicode control characters? switch (__icu4x_bionic_general_category(wc)) { case U_CONTROL_CHAR: return -1; case U_NON_SPACING_MARK: case U_ENCLOSING_MARK: return0; case U_FORMAT_CHAR: // A special case for soft hyphen (U+00AD) to match historical practice. // See the tests for more commentary. return (wc == 0x00ad) ? 1 : 0;
}
// Medial and final jamo render as zero width when used correctly, // so we handle them specially rather than relying on East Asian Width. switch (__icu4x_bionic_hangul_syllable_type(wc)) { case U_HST_VOWEL_JAMO: case U_HST_TRAILING_JAMO: return0; case U_HST_LEADING_JAMO: case U_HST_LV_SYLLABLE: case U_HST_LVT_SYLLABLE: return2;
}
// Hangeul choseong filler U+115F is default ignorable, so we check default // ignorability only after we've already handled Hangeul jamo above. if (__icu4x_bionic_is_default_ignorable_code_point(wc)) return0;
// A few weird special cases where EastAsianWidth is not helpful for us. if (wc >= 0x3248 && wc <= 0x4dff) { // Circled two-digit CJK "speed sign" numbers. EastAsianWidth is ambiguous, // but wide makes more sense. if (wc <= 0x324f) return2; // Hexagrams. EastAsianWidth is neutral, but wide seems better. if (wc >= 0x4dc0) return2;
}
// The EastAsianWidth property is at least defined by the Unicode standard! // https://www.unicode.org/reports/tr11/ switch (__icu4x_bionic_east_asian_width(wc)) { case U_EA_AMBIGUOUS: case U_EA_HALFWIDTH: case U_EA_NARROW: case U_EA_NEUTRAL: return1; case U_EA_FULLWIDTH: case U_EA_WIDE: return2;
}
return0;
}
int wcswidth(constwchar_t* wcs, size_t n) { int result = 0, width; for (size_t i = 0; i < n && wcs[i] != L'\0'; ++i) { if ((width = wcwidth(wcs[i])) == -1) return -1;
result += width;
} return result;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.