Skip to content

Commit 955405d

Browse files
krisman-at-collaboratytso
authored andcommitted
unicode: introduce UTF-8 character database
The decomposition and casefolding of UTF-8 characters are described in a prefix tree in utf8data.h, which is a generate from the Unicode Character Database (UCD), published by the Unicode Consortium, and should not be edited by hand. The structures in utf8data.h are meant to be used for lookup operations by the unicode subsystem, when decoding a utf-8 string. mkutf8data.c is the source for a program that generates utf8data.h. It was written by Olaf Weber from SGI and originally proposed to be merged into Linux in 2014. The original proposal performed the compatibility decomposition, NFKD, but the current version was modified by me to do canonical decomposition, NFD, as suggested by the community. The changes from the original submission are: * Rebase to mainline. * Fix out-of-tree-build. * Update makefile to build 11.0.0 ucd files. * drop references to xfs. * Convert NFKD to NFD. * Merge back robustness fixes from original patch. Requested by Dave Chinner. The original submission is archived at: <https://linux-xfs.oss.sgi.narkive.com/Xx10wjVY/rfc-unicode-utf-8-support-for-xfs> The utf8data.h file can be regenerated using the instructions in fs/unicode/README.utf8data. - Notes on the update from 8.0.0 to 11.0: The structure of the ucd files and special cases have not experienced any changes between versions 8.0.0 and 11.0.0. 8.0.0 saw the addition of Cherokee LC characters, which is an interesting case for case-folding. The update is accompanied by new tests on the test_ucd module to catch specific cases. No changes to mkutf8data script were required for the updates. Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.co.uk> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 310a997 commit 955405d

8 files changed

Lines changed: 17106 additions & 0 deletions

File tree

‎fs/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,5 +317,6 @@ endif # NETWORK_FILESYSTEMS
317317

318318
source "fs/nls/Kconfig"
319319
source "fs/dlm/Kconfig"
320+
source "fs/unicode/Kconfig"
320321

321322
endmenu

‎fs/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ obj-$(CONFIG_EXPORTFS) += exportfs/
9292
obj-$(CONFIG_NFSD) += nfsd/
9393
obj-$(CONFIG_LOCKD) += lockd/
9494
obj-$(CONFIG_NLS) += nls/
95+
obj-$(CONFIG_UNICODE) += unicode/
9596
obj-$(CONFIG_SYSV_FS) += sysv/
9697
obj-$(CONFIG_CIFS) += cifs/
9798
obj-$(CONFIG_HPFS_FS) += hpfs/

‎fs/unicode/Kconfig‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# UTF-8 normalization
3+
#
4+
config UNICODE
5+
bool "UTF-8 normalization and casefolding support"
6+
help
7+
Say Y here to enable UTF-8 NFD normalization and NFD+CF casefolding
8+
support.

‎fs/unicode/Makefile‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
# This rule is not invoked during the kernel compilation. It is used to
4+
# regenerate the utf8data.h header file.
5+
utf8data.h.new: *.txt $(objdir)/scripts/mkutf8data
6+
$(objdir)/scripts/mkutf8data \
7+
-a DerivedAge.txt \
8+
-c DerivedCombiningClass.txt \
9+
-p DerivedCoreProperties.txt \
10+
-d UnicodeData.txt \
11+
-f CaseFolding.txt \
12+
-n NormalizationCorrections.txt \
13+
-t NormalizationTest.txt \
14+
-o $@

‎fs/unicode/README.utf8data‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
The utf8data.h file in this directory is generated from the Unicode
2+
Character Database for version 11.0.0 of the Unicode standard.
3+
4+
The full set of files can be found here:
5+
6+
http://www.unicode.org/Public/11.0.0/ucd/
7+
8+
Individual source links:
9+
10+
http://www.unicode.org/Public/11.0.0/ucd/CaseFolding.txt
11+
http://www.unicode.org/Public/11.0.0/ucd/DerivedAge.txt
12+
http://www.unicode.org/Public/11.0.0/ucd/extracted/DerivedCombiningClass.txt
13+
http://www.unicode.org/Public/11.0.0/ucd/DerivedCoreProperties.txt
14+
http://www.unicode.org/Public/11.0.0/ucd/NormalizationCorrections.txt
15+
http://www.unicode.org/Public/11.0.0/ucd/NormalizationTest.txt
16+
http://www.unicode.org/Public/11.0.0/ucd/UnicodeData.txt
17+
18+
md5sums (verify by running "md5sum -c README.utf8data"):
19+
20+
414436796cf097df55f798e1585448ee CaseFolding.txt
21+
6032a595fbb782694456491d86eecfac DerivedAge.txt
22+
3240997d671297ac754ab0d27577acf7 DerivedCombiningClass.txt
23+
2a4fe257d9d8184518e036194d2248ec DerivedCoreProperties.txt
24+
4e7d383fa0dd3cd9d49d64e5b7b7c9e0 NormalizationCorrections.txt
25+
c9500c5b8b88e584469f056023ecc3f2 NormalizationTest.txt
26+
acc291106c3758d2025f8d7bd5518bee UnicodeData.txt
27+
28+
sha1sums (verify by running "sha1sum -c README.utf8data"):
29+
30+
9184727adf7bd20e36312a68581d12ba3ffb9854 CaseFolding.txt
31+
86c55b3eb89de61704da16af9c3f22854f61b57d DerivedAge.txt
32+
b615703f62b1dbc5110e91acc3ff8b3789a067cf DerivedCombiningClass.txt
33+
f8b07ef116d7dc21a94f26e70178ed2acf8713e9 DerivedCoreProperties.txt
34+
a5fafb8998c0b8153a2a58430b8a35c811db0abc NormalizationCorrections.txt
35+
070cdcb00cd4f0860e476750e404c59c2ebe9b25 NormalizationTest.txt
36+
0e060fafb08d6722fbec56d9f9ebe8509f01d0ee UnicodeData.txt
37+
38+
To update to the newer version of the Unicode standard, the latest
39+
released version of the UCD can be found here:
40+
41+
http://www.unicode.org/Public/UCD/latest/
42+
43+
To build the utf8data.h file, from a kernel tree that has been built,
44+
cd to this directory (fs/unicode) and run this command:
45+
46+
make C=../.. objdir=../.. utf8data.h.new
47+
48+
After sanity checking the newly generated utf8data.h.new file (the
49+
version generated from the 11.0.0 UCD should be 13,834 lines long, and
50+
have a total size of 1104k) and/or comparing it with the older version
51+
of utf8data.h, rename it to utf8data.h.
52+
53+
If you are a kernel developer updating to a newer version of the
54+
Unicode Character Database, please update this README.utf8data file
55+
with the version of the UCD that was used, the md5sum and sha1sums of
56+
the *.txt files, before checking in the new versions of the utf8data.h
57+
and README.utf8data files.

‎fs/unicode/utf8data.h‎

Lines changed: 13834 additions & 0 deletions
Large diffs are not rendered by default.

‎scripts/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ hostprogs-$(CONFIG_ASN1) += asn1_compiler
2020
hostprogs-$(CONFIG_MODULE_SIG) += sign-file
2121
hostprogs-$(CONFIG_SYSTEM_TRUSTED_KEYRING) += extract-cert
2222
hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert
23+
hostprogs-$(CONFIG_UNICODE) += mkutf8data
2324

2425
HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include
2526
HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include

0 commit comments

Comments
 (0)