1/* Part of SWI-Prolog 2 3 Author: Jan Wielemaker 4 E-mail: J.Wielemaker@vu.nl 5 WWW: http://www.swi-prolog.org 6 Copyright (c) 2010-2020, University of Amsterdam 7 CWI, Amsterdam 8 All rights reserved. 9 10 Redistribution and use in source and binary forms, with or without 11 modification, are permitted provided that the following conditions 12 are met: 13 14 1. Redistributions of source code must retain the above copyright 15 notice, this list of conditions and the following disclaimer. 16 17 2. Redistributions in binary form must reproduce the above copyright 18 notice, this list of conditions and the following disclaimer in 19 the documentation and/or other materials provided with the 20 distribution. 21 22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 POSSIBILITY OF SUCH DAMAGE. 34*/ 35 36:- module(unicode, 37 [ unicode_property/2, % ?Code, ?Property 38 unicode_map/3, % +In, -Out, +Options 39 unicode_nfd/2, % +In, -Out 40 unicode_nfc/2, % +In, -Out 41 unicode_nfkd/2, % +In, -Out 42 unicode_nfkc/2 % +In, -Out 43 ]). 44:- use_foreign_library(foreign(unicode4pl)).
90systemgoal_expansion(unicode_map(In, Out, Options),
91 unicode_map(In, Out, Mask)) :-
92 is_list(Options),
93 unicode_option_mask(Options, Mask).
compose
or decompose
.
150unicode_nfd(In, Out) :-
151 unicode_map(In, Out, [stable,decompose]).
161unicode_nfc(In, Out) :-
162 unicode_map(In, Out, [stable,compose]).
168unicode_nfkd(In, Out) :-
169 unicode_map(In, Out, [stable,decompose,compat]).
176unicode_nfkc(In, Out) :-
177 unicode_map(In, Out, [stable,compose,compat]).
unicode_property(C, category('L'))
214unicode_property(Code, Property) :- 215 nonvar(Code), nonvar(Property), 216 !, 217 '$unicode_property'(Code, Property). 218unicode_property(Code, Property) :- 219 nonvar(Code), 220 !, 221 property(Property), 222 '$unicode_property'(Code, Property). 223unicode_property(Code, Property) :- 224 var(Code), 225 !, 226 between(0, 0x10ffff, Code), 227 property(Property), 228 '$unicode_property'(Code, Property). 229 230property(category(_)). 231property(combining_class(_)). 232property(bidi_class(_)). 233property(decomp_type(_)). 234property(decomp_mapping(_)). 235property(bidi_mirrored(_)). 236property(uppercase_mapping(_)). 237property(lowercase_mapping(_)). 238property(titlecase_mapping(_)). 239property(comb1st_index(_)). 240property(comb2nd_index(_)). 241property(comp_exclusion(_)). 242property(ignorable(_)). 243property(control_boundary(_)). 244property(extend(_)). 245property(casefold_mapping(_))
Unicode string handling
This library is a wrapper around the utf8proc library, providing information about Unicode code-points and performing operations (mappings) on Unicode atoms. The central predicate is unicode_map/3, mapping a Unicode atom to another Unicode atom using a sequence of operations. The predicates unicode_nfd/2, unicode_nfc/2, unicode_nfkd/2 and unicode_nfkc/2 implement the four standard Unicode normalization forms.
Lump handling: