12.4.4.4 Wide-character versions
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • Analysing Terms via the Foreign Interface
            • Wide-character versions
              • PL_new_atom_wchars()
              • PL_atom_wchars()
              • PL_get_wchars()
              • PL_put_wchars()
              • PL_unify_wchars()
              • PL_unify_wchars_diff()
              • PL_wcwidth()
              • PL_is_id_start()
              • PL_is_id_continue()
              • PL_is_uppercase()
              • PL_is_decimal()
              • PL_is_layout()
    • Packages
Availability:C-language interface function
int PL_wcwidth(int chr)
Display column width of a Unicode code point chr. Returns 0 for combining and other zero-width characters, 2 for East Asian Wide and Fullwidth characters, 1 for ordinary printable characters, and -1 for control characters and code points unknown to the implementation.

The result is locale-independent and identical on every supported platform. Width data is sourced at table-build time from EastAsianWidth.txt (UAX #11) and the general-category property, and stored as two bits in each uflags_map entry alongside the syntax classification used by the parser; runtime lookups are a single byte fetch. The Unicode version that drives the table is reported by the unicode_syntax_version flag (see section 2.15.1.9).

The argument is a full 32-bit code point. Avoid casting to wchar_t before the call: wchar_t is 16-bit on Windows, and the cast silently drops non-BMP characters.