ICU 56.1: uspoof.h Source File

ICU 56.1 56.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

uspoof.h
Go to the documentation of this file.
1 /*
2 ***************************************************************************
3 * Copyright (C) 2008-2015, International Business Machines Corporation
4 * and others. All Rights Reserved.
5 ***************************************************************************
6 * file name: uspoof.h
7 * encoding: US-ASCII
8 * tab size: 8 (not used)
9 * indentation:4
10 *
11 * created on: 2008Feb13
12 * created by: Andy Heninger
13 *
14 * Unicode Spoof Detection
15 */
16
17 #ifndef USPOOF_H
18 #define USPOOF_H
19
20 #include "unicode/utypes.h"
21 #include "unicode/uset.h"
22 #include "unicode/parseerr.h"
23 #include "unicode/localpointer.h"
24
25 #if !UCONFIG_NO_NORMALIZATION
26
27
28 #if U_SHOW_CPLUSPLUS_API
29 #include "unicode/unistr.h"
30 #include "unicode/uniset.h"
31 #endif
32
33
152 struct USpoofChecker;
153 typedef struct USpoofChecker USpoofChecker;
162 typedef enum USpoofChecks {
168 USPOOF_SINGLE_SCRIPT_CONFUSABLE = 1,
169
178 USPOOF_MIXED_SCRIPT_CONFUSABLE = 2,
179
189 USPOOF_WHOLE_SCRIPT_CONFUSABLE = 4,
190
197 USPOOF_ANY_CASE = 8,
198
212 USPOOF_RESTRICTION_LEVEL = 16,
213
214 #ifndef U_HIDE_DEPRECATED_API
215
220 USPOOF_SINGLE_SCRIPT = USPOOF_RESTRICTION_LEVEL,
221 #endif /* U_HIDE_DEPRECATED_API */
222
229 USPOOF_INVISIBLE = 32,
230
235 USPOOF_CHAR_LIMIT = 64,
236
243 USPOOF_MIXED_NUMBERS = 128,
244
250 USPOOF_ALL_CHECKS = 0xFFFF,
251
264 USPOOF_AUX_INFO = 0x40000000
265
266 } USpoofChecks;
267
268
274 typedef enum URestrictionLevel {
280 USPOOF_ASCII = 0x10000000,
286 USPOOF_SINGLE_SCRIPT_RESTRICTIVE = 0x20000000,
294 USPOOF_HIGHLY_RESTRICTIVE = 0x30000000,
300 USPOOF_MODERATELY_RESTRICTIVE = 0x40000000,
306 USPOOF_MINIMALLY_RESTRICTIVE = 0x50000000,
312 USPOOF_UNRESTRICTIVE = 0x60000000,
318 USPOOF_RESTRICTION_LEVEL_MASK = 0x7F000000
319 } URestrictionLevel;
320
331 U_STABLE USpoofChecker * U_EXPORT2
332 uspoof_open(UErrorCode *status);
333
334
356 U_STABLE USpoofChecker * U_EXPORT2
357 uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
358 UErrorCode *pErrorCode);
359
391 U_STABLE USpoofChecker * U_EXPORT2
392 uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
393 const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,
394 int32_t *errType, UParseError *pe, UErrorCode *status);
395
396
402 U_STABLE void U_EXPORT2
403 uspoof_close(USpoofChecker *sc);
404
405 #if U_SHOW_CPLUSPLUS_API
406
407 U_NAMESPACE_BEGIN
408
418 U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close);
419
420 U_NAMESPACE_END
421
422 #endif
423
433 U_STABLE USpoofChecker * U_EXPORT2
434 uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
435
436
449 U_STABLE void U_EXPORT2
450 uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
451
463 U_STABLE int32_t U_EXPORT2
464 uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);
465
474 U_STABLE void U_EXPORT2
475 uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel);
476
477
485 U_STABLE URestrictionLevel U_EXPORT2
486 uspoof_getRestrictionLevel(const USpoofChecker *sc);
487
530 U_STABLE void U_EXPORT2
531 uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
532
554 U_STABLE const char * U_EXPORT2
555 uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status);
556
557
576 U_STABLE void U_EXPORT2
577 uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status);
578
579
600 U_STABLE const USet * U_EXPORT2
601 uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status);
602
603
604 #if U_SHOW_CPLUSPLUS_API
605
623 U_STABLE void U_EXPORT2
624 uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status);
625
626
647 U_STABLE const icu::UnicodeSet * U_EXPORT2
648 uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status);
649 #endif
650
651
678 U_STABLE int32_t U_EXPORT2
679 uspoof_check(const USpoofChecker *sc,
680 const UChar *id, int32_t length,
681 int32_t *position,
682 UErrorCode *status);
683
684
712 U_STABLE int32_t U_EXPORT2
713 uspoof_checkUTF8(const USpoofChecker *sc,
714 const char *id, int32_t length,
715 int32_t *position,
716 UErrorCode *status);
717
718
719 #if U_SHOW_CPLUSPLUS_API
720
743 U_STABLE int32_t U_EXPORT2
744 uspoof_checkUnicodeString(const USpoofChecker *sc,
745 const icu::UnicodeString &id,
746 int32_t *position,
747 UErrorCode *status);
748
749 #endif
750
751
791 U_STABLE int32_t U_EXPORT2
792 uspoof_areConfusable(const USpoofChecker *sc,
793 const UChar *id1, int32_t length1,
794 const UChar *id2, int32_t length2,
795 UErrorCode *status);
796
797
798
824 U_STABLE int32_t U_EXPORT2
825 uspoof_areConfusableUTF8(const USpoofChecker *sc,
826 const char *id1, int32_t length1,
827 const char *id2, int32_t length2,
828 UErrorCode *status);
829
830
831
832
833 #if U_SHOW_CPLUSPLUS_API
834
855 U_STABLE int32_t U_EXPORT2
856 uspoof_areConfusableUnicodeString(const USpoofChecker *sc,
857 const icu::UnicodeString &s1,
858 const icu::UnicodeString &s2,
859 UErrorCode *status);
860 #endif
861
862
895 U_STABLE int32_t U_EXPORT2
896 uspoof_getSkeleton(const USpoofChecker *sc,
897 uint32_t type,
898 const UChar *id, int32_t length,
899 UChar *dest, int32_t destCapacity,
900 UErrorCode *status);
901
937 U_STABLE int32_t U_EXPORT2
938 uspoof_getSkeletonUTF8(const USpoofChecker *sc,
939 uint32_t type,
940 const char *id, int32_t length,
941 char *dest, int32_t destCapacity,
942 UErrorCode *status);
943
944 #if U_SHOW_CPLUSPLUS_API
945
970 U_I18N_API icu::UnicodeString & U_EXPORT2
971 uspoof_getSkeletonUnicodeString(const USpoofChecker *sc,
972 uint32_t type,
973 const icu::UnicodeString &id,
974 icu::UnicodeString &dest,
975 UErrorCode *status);
976 #endif /* U_SHOW_CPLUSPLUS_API */
977
989 U_STABLE const USet * U_EXPORT2
990 uspoof_getInclusionSet(UErrorCode *status);
991
1003 U_STABLE const USet * U_EXPORT2
1004 uspoof_getRecommendedSet(UErrorCode *status);
1005
1006 #if U_SHOW_CPLUSPLUS_API
1007
1019 U_STABLE const icu::UnicodeSet * U_EXPORT2
1020 uspoof_getInclusionUnicodeSet(UErrorCode *status);
1021
1033 U_STABLE const icu::UnicodeSet * U_EXPORT2
1034 uspoof_getRecommendedUnicodeSet(UErrorCode *status);
1035
1036 #endif /* U_SHOW_CPLUSPLUS_API */
1037
1060 U_STABLE int32_t U_EXPORT2
1061 uspoof_serialize(USpoofChecker *sc,
1062 void *data, int32_t capacity,
1063 UErrorCode *status);
1064
1065
1066 #endif
1067
1068 #endif /* USPOOF_H */
uspoof_getInclusionSet
const USet * uspoof_getInclusionSet(UErrorCode *status)
Get the set of Candidate Characters for Inclusion in Identifiers, as defined in Unicode UAX #31...
uspoof_getInclusionUnicodeSet
const icu::UnicodeSet * uspoof_getInclusionUnicodeSet(UErrorCode *status)
Get the set of Candidate Characters for Inclusion in Identifiers, as defined in Unicode UAX #31...
uspoof_checkUnicodeString
int32_t uspoof_checkUnicodeString(const USpoofChecker *sc, const icu::UnicodeString &id, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
uspoof_close
void uspoof_close(USpoofChecker *sc)
Close a Spoof Checker, freeing any memory that was being held by its implementation.
URestrictionLevel
URestrictionLevel
Constants from UAX #39 for use in setRestrictionLevel(), and for returned identifier restriction leve...
Definition: uspoof.h:274
USPOOF_INVISIBLE
Check an identifier for the presence of invisible characters, such as zero-width spaces, or character sequences that are likely not to display, such as multiple occurrences of the same non-spacing mark.
Definition: uspoof.h:229
USPOOF_SINGLE_SCRIPT
Check that an identifier contains only characters from a single script (plus chars from the common an...
Definition: uspoof.h:220
uspoof_setChecks
void uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status)
Specify the set of checks that will be performed by the check functions of this Spoof Checker...
uspoof_clone
USpoofChecker * uspoof_clone(const USpoofChecker *sc, UErrorCode *status)
Clone a Spoof Checker.
USPOOF_ASCII
Only ASCII characters: U+0000..U+007F.
Definition: uspoof.h:280
USPOOF_CHAR_LIMIT
Check that an identifier contains only characters from a specified set of acceptable characters...
Definition: uspoof.h:235
USPOOF_MINIMALLY_RESTRICTIVE
Allow arbitrary mixtures of scripts.
Definition: uspoof.h:306
USpoofChecks
USpoofChecks
Enum for the kinds of checks that USpoofChecker can perform.
Definition: uspoof.h:162
unistr.h
C++ API: Unicode String.
uspoof_open
USpoofChecker * uspoof_open(UErrorCode *status)
Create a Unicode Spoof Checker, configured to perform all checks except for USPOOF_LOCALE_LIMIT and U...
uspoof_check
int32_t uspoof_check(const USpoofChecker *sc, const UChar *id, int32_t length, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
uspoof_setAllowedLocales
void uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status)
Limit characters that are acceptable in identifiers being checked to those normally used with the lan...
uspoof_getChecks
int32_t uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status)
Get the set of checks that this Spoof Checker has been configured to perform.
uspoof_openFromSource
USpoofChecker * uspoof_openFromSource(const char *confusables, int32_t confusablesLen, const char *confusablesWholeScript, int32_t confusablesWholeScriptLen, int32_t *errType, UParseError *pe, UErrorCode *status)
Open a Spoof Checker from the source form of the spoof data.
uspoof_getRestrictionLevel
URestrictionLevel uspoof_getRestrictionLevel(const USpoofChecker *sc)
Get the Restriction Level that will be tested if the checks include RESTRICTION_LEVEL.
uspoof_getAllowedUnicodeSet
const icu::UnicodeSet * uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status)
Get a UnicodeSet for the characters permitted in an identifier.
uset.h
C API: Unicode Set.
USPOOF_ALL_CHECKS
Enable all spoof checks.
Definition: uspoof.h:250
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
uspoof_getRecommendedUnicodeSet
const icu::UnicodeSet * uspoof_getRecommendedUnicodeSet(UErrorCode *status)
Get the set of characters from Recommended Scripts for Inclusion in Identifiers, as defined in Unicod...
uspoof_areConfusableUnicodeString
int32_t uspoof_areConfusableUnicodeString(const USpoofChecker *sc, const icu::UnicodeString &s1, const icu::UnicodeString &s2, UErrorCode *status)
Check the whether two specified strings are visually confusable.
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
USPOOF_ANY_CASE
Any Case Modifier for confusable identifier tests.
Definition: uspoof.h:197
uspoof_checkUTF8
int32_t uspoof_checkUTF8(const USpoofChecker *sc, const char *id, int32_t length, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
USPOOF_WHOLE_SCRIPT_CONFUSABLE
Whole script confusable test.
Definition: uspoof.h:189
U_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:535
uspoof_getSkeletonUnicodeString
U_I18N_API icu::UnicodeString & uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, uint32_t type, const icu::UnicodeString &id, icu::UnicodeString &dest, UErrorCode *status)
Get the "skeleton" for an identifier.
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
uspoof_getSkeleton
int32_t uspoof_getSkeleton(const USpoofChecker *sc, uint32_t type, const UChar *id, int32_t length, UChar *dest, int32_t destCapacity, UErrorCode *status)
Get the "skeleton" for an identifier.
USPOOF_MODERATELY_RESTRICTIVE
Allow Latin with other scripts except Cyrillic, Greek, Cherokee Otherwise, the same as Highly Restric...
Definition: uspoof.h:300
USPOOF_MIXED_NUMBERS
Check that an identifier does not include decimal digits from more than one numbering system...
Definition: uspoof.h:243
uspoof_setAllowedChars
void uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status)
Limit the acceptable characters to those specified by a Unicode Set.
USPOOF_SINGLE_SCRIPT_RESTRICTIVE
All characters in each identifier must be from a single script.
Definition: uspoof.h:286
USPOOF_HIGHLY_RESTRICTIVE
All characters in each identifier must be from a single script, or from the combinations: Latin + Han...
Definition: uspoof.h:294
uspoof_getAllowedChars
const USet * uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status)
Get a USet for the characters permitted in an identifier.
uspoof_openFromSerialized
USpoofChecker * uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength, UErrorCode *pErrorCode)
Open a Spoof checker from its serialized form, stored in 32-bit-aligned memory.
uspoof_getSkeletonUTF8
int32_t uspoof_getSkeletonUTF8(const USpoofChecker *sc, uint32_t type, const char *id, int32_t length, char *dest, int32_t destCapacity, UErrorCode *status)
Get the "skeleton" for an identifier.
icu::UnicodeSet
A mutable set of Unicode characters and multicharacter strings.
Definition: uniset.h:276
USpoofChecker
struct USpoofChecker USpoofChecker
typedef for C of USpoofChecker
Definition: uspoof.h:153
uspoof_serialize
int32_t uspoof_serialize(USpoofChecker *sc, void *data, int32_t capacity, UErrorCode *status)
Serialize the data for a spoof detector into a chunk of memory.
LocalUSpoofCheckerPointer
"Smart pointer" class, closes a USpoofChecker via uspoof_close().
uspoof_setRestrictionLevel
void uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel)
Set the loosest restriction level allowed.
USPOOF_SINGLE_SCRIPT_CONFUSABLE
Single script confusable test.
Definition: uspoof.h:168
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:312
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
USet
struct USet USet
Definition: ucnv.h:67
parseerr.h
C API: Parse Error Information.
uspoof_areConfusableUTF8
int32_t uspoof_areConfusableUTF8(const USpoofChecker *sc, const char *id1, int32_t length1, const char *id2, int32_t length2, UErrorCode *status)
Check the whether two specified strings are visually confusable.
uspoof_getAllowedLocales
const char * uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status)
Get a list of locales for the scripts that are acceptable in strings to be checked.
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
USPOOF_MIXED_SCRIPT_CONFUSABLE
Mixed script confusable test.
Definition: uspoof.h:178
USPOOF_AUX_INFO
Enable the return of auxillary (non-error) information in the upper bits of the check results value...
Definition: uspoof.h:264
USPOOF_RESTRICTION_LEVEL
Check that an identifier is no looser than the specified RestrictionLevel.
Definition: uspoof.h:212
uspoof_setAllowedUnicodeSet
void uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status)
Limit the acceptable characters to those specified by a Unicode Set.
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:56
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
USPOOF_RESTRICTION_LEVEL_MASK
Mask for selecting the Restriction Level bits from the return value of uspoof_check().
Definition: uspoof.h:318
uspoof_getRecommendedSet
const USet * uspoof_getRecommendedSet(UErrorCode *status)
Get the set of characters from Recommended Scripts for Inclusion in Identifiers, as defined in Unicod...
USPOOF_UNRESTRICTIVE
Any valid identifiers, including characters outside of the Identifier Profile.
Definition: uspoof.h:312
uspoof_areConfusable
int32_t uspoof_areConfusable(const USpoofChecker *sc, const UChar *id1, int32_t length1, const UChar *id2, int32_t length2, UErrorCode *status)
Check the whether two specified strings are visually confusable.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:109
uniset.h
C++ API: Unicode Set.