This library wraps the utf8proc library, giving Prolog code access to Unicode character properties, string normalization, case folding, and grapheme-cluster iteration.
Three levels of API are provided:
Grapheme clusters (user-perceived characters) can be iterated with atom_graphemes/2 and string_graphemes/2.
Lump handling:
U+0020 <-- all space characters (general category Zs)
U+0027 ' <-- left/right single quotation mark U+2018..2019,
modifier letter apostrophe U+02BC,
modifier letter vertical line U+02C8
U+002D - <-- all dash characters (general category Pd),
minus U+2212
U+002F / <-- fraction slash U+2044,
division slash U+2215
U+003A : <-- ratio U+2236
U+003C < <-- single left-pointing angle quotation mark U+2039,
left-pointing angle bracket U+2329,
left angle bracket U+3008
U+003E > <-- single right-pointing angle quotation mark U+203A,
right-pointing angle bracket U+232A,
right angle bracket U+3009
U+005C \ <-- set minus U+2216
U+005E ^ <-- modifier letter up arrowhead U+02C4,
modifier letter circumflex accent U+02C6,
caret U+2038,
up arrowhead U+2303
U+005F _ <-- all connector characters (general category Pc),
modifier letter low macron U+02CD
U+0060 ` <-- modifier letter grave accent U+02CB
U+007C | <-- divides U+2223
U+007E ~ <-- tilde operator U+223C
@see http://www.unicode.org/reports/tr15/ (UAX#15 Normalization) @see http://www.unicode.org/reports/tr29/ (UAX#29 Grapheme Clusters) @see http://www.unicode.org/reports/tr31/ (UAX#31 Identifiers) @see https://github.com/JuliaStrings/utf8proc
utf8proc_map(In, Options) in the C
API.
compat).
nlf2lf, paragraph and line separators become U+000A as
well.
compose or decompose.
'Strasse' written with U+00DF (LATIN SMALL LETTER SHARP S)
maps to 'strasse', and U+FB03 (LATIN SMALL LIGATURE FFI)
maps to 'ffi'.This predicate is a thin wrapper over utf8proc's property struct, so its vocabulary matches the utf8proc documentation. In the modes (+,?) and (-,?) the predicate enumerates properties for the given code (or the code for the given property); in (+,+) it is a deterministic test.
Supported properties:
cc, cf, cn,
co, cs, ll, lm, lo, lt, lu, mc, me, mn,
nd, nl, no, pc, pd, pe, pf, pi, po, ps,
sc, sk, sm, so, zl, zp, zs.
When querying, the single capital letter of a subcategory stands for all
its subcategories; e.g.
?- unicode_property(0'A, category('L')).
true.
l, lre, lro, r, al,
rle, rlo, pdf, en, es, et, an, cs, nsm,
bn, b, s, ws, on.
true if the character is mirrored for bidi (parentheses,
brackets, math operators, ...).
font, nobreak,
initial, medial, final, isolated, circle, super,
sub, vertical, wide, narrow, small, square,
fraction, compat. Fails when there is no
decomposition.
true if the character is a "default ignorable" code point.
start,
other, cr, lf, control, extend, l, v, t,
lv, lvt, regional_indicator, spacingmark, prepend,
zwj, extended_pictographic, e_zwg.
true if the character has East-Asian Ambiguous width ---
normally one column, but two in a legacy CJK context.
unicode_property(0'A, uppercase(_))
fails because 'A' is already upper-case). For characters
whose case mapping produces more than one code point (e.g. U+00DF LATIN
SMALL LETTER SHARP S maps to "SS"), use unicode_map/3
with the [casefold] option or
unicode_casefold/2 for a
full string-level transformation.
none, linker, consonant, extend.
Used by the grapheme-cluster-break algorithm for Devanagari, Bengali,
etc.
e + U+0301 are both one grapheme, an
emoji ZWJ sequence such as MAN + ZWJ + WOMAN + ZWJ + GIRL
is one grapheme, and a regional-indicator pair (e.g. U+1F1F3 U+1F1F1,
rendered as the Dutch flag) is one grapheme.
In the forward mode (+Atom, ?Graphemes), Atom is decomposed into a list of atoms, each covering one cluster. In the reverse mode (?Atom, +Graphemes), the elements of Graphemes are concatenated into Atom. Both arguments instantiated means both modes run and the result must agree.
?- atom_codes(A, [0'c, 0'a, 0'f, 0'e, 0x0301]), atom_graphemes(A, Gs). Gs = [c, a, f, G], atom_codes(G, [0'e, 0x0301]). ?- atom_graphemes(A, [a, b, c]). A = abc.
'15.1.0'.Copyright (c) 2009 Public Software Group e. V., Berlin, Germany
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This software distribution contains derived data from a modified version of the Unicode data files. The following license applies to that data:
COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1991-2007 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
Permission is hereby granted, free of charge, to any person obtaining a copy of the Unicode data files and any associated documentation (the "Data Files") or Unicode software and any associated documentation (the "Software") to deal in the Data Files or Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Data Files or Software, and to permit persons to whom the Data Files or Software are furnished to do so, provided that (a) the above copyright notice(s) and this permission notice appear with all copies of the Data Files or Software, (b) both the above copyright notice(s) and this permission notice appear in associated documentation, and (c) there is clear notice in each modified Data File or in the Software as well as in the documentation associated with the Data File(s) or Software that the data or software has been modified.
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR SOFTWARE.
Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in these Data Files or Software without prior written authorization of the copyright holder.
Unicode and the Unicode logo are trademarks of Unicode, Inc., and may be registered in some jurisdictions. All other trademarks and registered trademarks mentioned herein are the property of their respective owners.