[PATCH] Implemented llvm::sys::locale::columnWidth and isPrint for Linux (addresses PR14910).

Alexander Kornienko alexfh at google.com
Wed Jul 10 06:56:01 PDT 2013


Hi jordan_rose, gribozavr,

The implementation doesn't rely on setlocale and any locale-specific
library functions, so it can probably be used in MacOS and Windows (in case
someone can test this). The code treats strings as UTF-8 (with proper checks).

Implementation of columnWidth uses Markus Kuhn's public domain implementation of
wcwidth. isPrint uses a similar code, but the data is generated by me from the
UCD (www.unicode.org/Public/UCD), the generator script is included in the patch.
Unit tests are included as well.

I'm not a Unicode expert, so I may have misinterpreted the meaning of
"printable". This patch treats all characters as printable except for control
characters, non-characters and reserved characters (categories Cn, Cc, Cf, Co,
Cs in UCD terminology).

http://llvm-reviews.chandlerc.com/D1121

Files:
  lib/Support/CMakeLists.txt
  lib/Support/LocaleGeneric.inc
  lib/Support/wctype_control_ranges.inc
  lib/Support/wcwidth.c
  unittests/Support/CMakeLists.txt
  unittests/Support/LocaleTest.cpp
  utils/unicode
  utils/unicode/DerivedGeneralCategory.txt
  utils/unicode/genwctype.sh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1121.1.patch
Type: text/x-patch
Size: 256908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130710/6e41daed/attachment.bin>


More information about the llvm-commits mailing list