Debian Codegraph @

contrib/unicode/README

raw
1 This directory contains a mechanism for GCC to have its own internal
2 implementation of wcwidth functionality (cpp_wcwidth () in libcpp/charset.c),
3 as well as a mechanism to update the information about codepoints permitted in
4 identifiers, which is encoded in libcpp/ucnid.h, and mapping between Unicode
5 names and codepoints, which is encoded in libcpp/uname2c.h.
6
7 The idea is to produce the necessary lookup tables
8 (../../libcpp/{ucnid.h,uname2c.h,generated_cpp_wcwidth.h}) in a reproducible
9 way, starting from the following files that are distributed by the Unicode
10 Consortium:
11
12 ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
13 ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt
14 ftp://ftp.unicode.org/Public/UNIDATA/PropList.txt
15 ftp://ftp.unicode.org/Public/UNIDATA/DerivedNormalizationProps.txt
16 ftp://ftp.unicode.org/Public/UNIDATA/DerivedCoreProperties.txt
17 ftp://ftp.unicode.org/Public/UNIDATA/NameAliases.txt
18
19 Three additional files are needed for lookup tables in libstdc++:
20
21 ftp://ftp.unicode.org/Public/UNIDATA/auxiliary/GraphemeBreakProperty.txt
22 ftp://ftp.unicode.org/Public/UNIDATA/emoji/emoji-data.txt
23 ftp://ftp.unicode.org/Public/UNIDATA/extracted/DerivedGeneralCategory.txt
24
25 All these files have been added to source control in this directory;
26 please see unicode-license.txt for the relevant copyright information.
27
28 In order to keep in sync with glibc's wcwidth as much as possible, it is
29 desirable for the logic that processes the Unicode data to be the same as
30 glibc's. To that end, we also put in this directory, in the from_glibc/
31 directory, the glibc python code that implements their logic. This code was
32 copied verbatim from glibc, and it can be updated at any time from the glibc
33 source code repository. The files copied from that repository are:
34
35 localedata/unicode-gen/unicode_utils.py
36 localedata/unicode-gen/utf8_gen.py
37
38 And the most recent versions added to GCC are from glibc git commit:
39 064c708c78cc2a6b5802dce73108fc0c1c6bfc80
40
41 The script gen_wcwidth.py found here contains the GCC-specific code to
42 map glibc's output to the lookup tables we require. This script should not need
43 to change, unless there are structural changes to the Unicode data files or to
44 the glibc code. Similarly, makeucnid.cc in ../../libcpp contains the logic to
45 produce ucnid.h.
46
47 The procedure to update GCC's Unicode support is the following:
48
49 1. Update the six Unicode data files from the above URLs.
50
51 2. Update the two glibc files in from_glibc/ from glibc's git. Update
52 the commit number above in this README.
53
54 3. Run ./gen_wcwidth.py X.Y > ../../libcpp/generated_cpp_wcwidth.h
55 (where X.Y is the version of the Unicode standard corresponding to the
56 Unicode data files being used, most recently, 16.0.0).
57
58 4. Update Unicode Copyright years in libcpp/makeucnid.cc and in
59 libcpp/makeuname2c.cc up to the year in which the Unicode
60 standard has been released.
61
62 5. Compile makeucnid, e.g. with:
63 g++ -O2 ../../libcpp/makeucnid.cc -o ../../libcpp/makeucnid
64
65 6. Generate ucnid.h as follows:
66 ../../libcpp/makeucnid ../../libcpp/ucnid.tab UnicodeData.txt \
67 DerivedNormalizationProps.txt DerivedCoreProperties.txt \
68 > ../../libcpp/ucnid.h
69
70 7. Read the corresponding Unicode's standard and update correspondingly
71 generated_ranges table in libcpp/makeuname2c.cc (in Unicode 16 all
72 the needed information was in Table 4-8).
73
74 8. Compile makeuname2c, e.g. with:
75 g++ -O2 ../../libcpp/makeuname2c.cc -o ../../libcpp/makeuname2c
76
77 9: Generate uname2c.h as follows:
78 ../../libcpp/makeuname2c UnicodeData.txt NameAliases.txt \
79 > ../../libcpp/uname2c.h
80
81 See gen_libstdcxx_unicode_data.py for instructions on updating the lookup
82 tables in libstdc++.