00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef USPOOF_H
00020 #define USPOOF_H
00021
00022 #include "unicode/utypes.h"
00023 #include "unicode/uset.h"
00024 #include "unicode/parseerr.h"
00025 #include "unicode/localpointer.h"
00026
00027 #if !UCONFIG_NO_NORMALIZATION
00028
00029
00030 #if U_SHOW_CPLUSPLUS_API
00031 #include "unicode/unistr.h"
00032 #include "unicode/uniset.h"
00033 #endif
00034
00035
00356 U_CDECL_BEGIN
00357
00358 struct USpoofChecker;
00362 typedef struct USpoofChecker USpoofChecker;
00364 struct USpoofCheckResult;
00369 typedef struct USpoofCheckResult USpoofCheckResult;
00370
00378 typedef enum USpoofChecks {
00387 USPOOF_SINGLE_SCRIPT_CONFUSABLE = 1,
00388
00397 USPOOF_MIXED_SCRIPT_CONFUSABLE = 2,
00398
00407 USPOOF_WHOLE_SCRIPT_CONFUSABLE = 4,
00408
00418 USPOOF_CONFUSABLE = USPOOF_SINGLE_SCRIPT_CONFUSABLE | USPOOF_MIXED_SCRIPT_CONFUSABLE | USPOOF_WHOLE_SCRIPT_CONFUSABLE,
00419
00420 #ifndef U_HIDE_DEPRECATED_API
00421
00426 USPOOF_ANY_CASE = 8,
00427 #endif
00428
00442 USPOOF_RESTRICTION_LEVEL = 16,
00443
00444 #ifndef U_HIDE_DEPRECATED_API
00445
00450 USPOOF_SINGLE_SCRIPT = USPOOF_RESTRICTION_LEVEL,
00451 #endif
00452
00459 USPOOF_INVISIBLE = 32,
00460
00466 USPOOF_CHAR_LIMIT = 64,
00467
00474 USPOOF_MIXED_NUMBERS = 128,
00475
00495 USPOOF_HIDDEN_OVERLAY = 256,
00496
00502 USPOOF_ALL_CHECKS = 0xFFFF,
00503
00516 USPOOF_AUX_INFO = 0x40000000
00517
00518 } USpoofChecks;
00519
00520
00530 typedef enum URestrictionLevel {
00537 USPOOF_ASCII = 0x10000000,
00544 USPOOF_SINGLE_SCRIPT_RESTRICTIVE = 0x20000000,
00558 USPOOF_HIGHLY_RESTRICTIVE = 0x30000000,
00566 USPOOF_MODERATELY_RESTRICTIVE = 0x40000000,
00572 USPOOF_MINIMALLY_RESTRICTIVE = 0x50000000,
00578 USPOOF_UNRESTRICTIVE = 0x60000000,
00584 USPOOF_RESTRICTION_LEVEL_MASK = 0x7F000000,
00585 #ifndef U_HIDE_INTERNAL_API
00586
00590 USPOOF_UNDEFINED_RESTRICTIVE = -1
00591 #endif
00592 } URestrictionLevel;
00593
00604 U_STABLE USpoofChecker * U_EXPORT2
00605 uspoof_open(UErrorCode *status);
00606
00607
00629 U_STABLE USpoofChecker * U_EXPORT2
00630 uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
00631 UErrorCode *pErrorCode);
00632
00663 U_STABLE USpoofChecker * U_EXPORT2
00664 uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
00665 const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,
00666 int32_t *errType, UParseError *pe, UErrorCode *status);
00667
00668
00674 U_STABLE void U_EXPORT2
00675 uspoof_close(USpoofChecker *sc);
00676
00686 U_STABLE USpoofChecker * U_EXPORT2
00687 uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
00688
00689
00727 U_STABLE void U_EXPORT2
00728 uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
00729
00741 U_STABLE int32_t U_EXPORT2
00742 uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);
00743
00755 U_STABLE void U_EXPORT2
00756 uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel);
00757
00758
00766 U_STABLE URestrictionLevel U_EXPORT2
00767 uspoof_getRestrictionLevel(const USpoofChecker *sc);
00768
00811 U_STABLE void U_EXPORT2
00812 uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
00813
00835 U_STABLE const char * U_EXPORT2
00836 uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status);
00837
00838
00857 U_STABLE void U_EXPORT2
00858 uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status);
00859
00860
00881 U_STABLE const USet * U_EXPORT2
00882 uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status);
00883
00884
00917 U_STABLE int32_t U_EXPORT2
00918 uspoof_check(const USpoofChecker *sc,
00919 const UChar *id, int32_t length,
00920 int32_t *position,
00921 UErrorCode *status);
00922
00923
00956 U_STABLE int32_t U_EXPORT2
00957 uspoof_checkUTF8(const USpoofChecker *sc,
00958 const char *id, int32_t length,
00959 int32_t *position,
00960 UErrorCode *status);
00961
00962
00991 U_STABLE int32_t U_EXPORT2
00992 uspoof_check2(const USpoofChecker *sc,
00993 const UChar* id, int32_t length,
00994 USpoofCheckResult* checkResult,
00995 UErrorCode *status);
00996
01028 U_STABLE int32_t U_EXPORT2
01029 uspoof_check2UTF8(const USpoofChecker *sc,
01030 const char *id, int32_t length,
01031 USpoofCheckResult* checkResult,
01032 UErrorCode *status);
01033
01052 U_STABLE USpoofCheckResult* U_EXPORT2
01053 uspoof_openCheckResult(UErrorCode *status);
01054
01062 U_STABLE void U_EXPORT2
01063 uspoof_closeCheckResult(USpoofCheckResult *checkResult);
01064
01079 U_STABLE int32_t U_EXPORT2
01080 uspoof_getCheckResultChecks(const USpoofCheckResult *checkResult, UErrorCode *status);
01081
01092 U_STABLE URestrictionLevel U_EXPORT2
01093 uspoof_getCheckResultRestrictionLevel(const USpoofCheckResult *checkResult, UErrorCode *status);
01094
01106 U_STABLE const USet* U_EXPORT2
01107 uspoof_getCheckResultNumerics(const USpoofCheckResult *checkResult, UErrorCode *status);
01108
01109
01153 U_STABLE int32_t U_EXPORT2
01154 uspoof_areConfusable(const USpoofChecker *sc,
01155 const UChar *id1, int32_t length1,
01156 const UChar *id2, int32_t length2,
01157 UErrorCode *status);
01158
01159
01160
01186 U_STABLE int32_t U_EXPORT2
01187 uspoof_areConfusableUTF8(const USpoofChecker *sc,
01188 const char *id1, int32_t length1,
01189 const char *id2, int32_t length2,
01190 UErrorCode *status);
01191
01192
01193
01194
01226 U_STABLE int32_t U_EXPORT2
01227 uspoof_getSkeleton(const USpoofChecker *sc,
01228 uint32_t type,
01229 const UChar *id, int32_t length,
01230 UChar *dest, int32_t destCapacity,
01231 UErrorCode *status);
01232
01266 U_STABLE int32_t U_EXPORT2
01267 uspoof_getSkeletonUTF8(const USpoofChecker *sc,
01268 uint32_t type,
01269 const char *id, int32_t length,
01270 char *dest, int32_t destCapacity,
01271 UErrorCode *status);
01272
01285 U_STABLE const USet * U_EXPORT2
01286 uspoof_getInclusionSet(UErrorCode *status);
01287
01300 U_STABLE const USet * U_EXPORT2
01301 uspoof_getRecommendedSet(UErrorCode *status);
01302
01325 U_STABLE int32_t U_EXPORT2
01326 uspoof_serialize(USpoofChecker *sc,
01327 void *data, int32_t capacity,
01328 UErrorCode *status);
01329
01330 U_CDECL_END
01331
01332 #if U_SHOW_CPLUSPLUS_API
01333
01334 U_NAMESPACE_BEGIN
01335
01350 U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close);
01368 U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckResultPointer, USpoofCheckResult, uspoof_closeCheckResult);
01371 U_NAMESPACE_END
01372
01391 U_STABLE void U_EXPORT2
01392 uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status);
01393
01394
01415 U_STABLE const icu::UnicodeSet * U_EXPORT2
01416 uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status);
01417
01446 U_STABLE int32_t U_EXPORT2
01447 uspoof_checkUnicodeString(const USpoofChecker *sc,
01448 const icu::UnicodeString &id,
01449 int32_t *position,
01450 UErrorCode *status);
01451
01477 U_STABLE int32_t U_EXPORT2
01478 uspoof_check2UnicodeString(const USpoofChecker *sc,
01479 const icu::UnicodeString &id,
01480 USpoofCheckResult* checkResult,
01481 UErrorCode *status);
01482
01504 U_STABLE int32_t U_EXPORT2
01505 uspoof_areConfusableUnicodeString(const USpoofChecker *sc,
01506 const icu::UnicodeString &s1,
01507 const icu::UnicodeString &s2,
01508 UErrorCode *status);
01509
01533 U_I18N_API icu::UnicodeString & U_EXPORT2
01534 uspoof_getSkeletonUnicodeString(const USpoofChecker *sc,
01535 uint32_t type,
01536 const icu::UnicodeString &id,
01537 icu::UnicodeString &dest,
01538 UErrorCode *status);
01539
01552 U_STABLE const icu::UnicodeSet * U_EXPORT2
01553 uspoof_getInclusionUnicodeSet(UErrorCode *status);
01554
01567 U_STABLE const icu::UnicodeSet * U_EXPORT2
01568 uspoof_getRecommendedUnicodeSet(UErrorCode *status);
01569
01570 #endif
01571
01572 #endif
01573
01574 #endif