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-2013, University of Amsterdam 7 All rights reserved. 8 9 Redistribution and use in source and binary forms, with or without 10 modification, are permitted provided that the following conditions 11 are met: 12 13 1. Redistributions of source code must retain the above copyright 14 notice, this list of conditions and the following disclaimer. 15 16 2. Redistributions in binary form must reproduce the above copyright 17 notice, this list of conditions and the following disclaimer in 18 the documentation and/or other materials provided with the 19 distribution. 20 21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 31 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 POSSIBILITY OF SUCH DAMAGE. 33*/ 34 35:- module(unicode, 36 [ unicode_property/2, % ?Code, ?Property 37 unicode_map/3, % +In, -Out, +Options 38 unicode_nfd/2, % +In, -Out 39 unicode_nfc/2, % +In, -Out 40 unicode_nfkd/2, % +In, -Out 41 unicode_nfkc/2 % +In, -Out 42 ]). 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: