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
00026 #if !UCONFIG_NO_NORMALIZATION
00027
00028
00029 #if U_SHOW_CPLUSPLUS_API
00030 #include "unicode/localpointer.h"
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_CAPI USpoofChecker * U_EXPORT2
00605 uspoof_open(UErrorCode *status);
00606
00607
00629 U_CAPI USpoofChecker * U_EXPORT2
00630 uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
00631 UErrorCode *pErrorCode);
00632
00663 U_CAPI 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_CAPI void U_EXPORT2
00675 uspoof_close(USpoofChecker *sc);
00676
00686 U_CAPI USpoofChecker * U_EXPORT2
00687 uspoof_clone(const USpoofChecker *sc, UErrorCode *status);
00688
00689
00730 U_CAPI void U_EXPORT2
00731 uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
00732
00744 U_CAPI int32_t U_EXPORT2
00745 uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status);
00746
00758 U_CAPI void U_EXPORT2
00759 uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel);
00760
00761
00769 U_CAPI URestrictionLevel U_EXPORT2
00770 uspoof_getRestrictionLevel(const USpoofChecker *sc);
00771
00814 U_CAPI void U_EXPORT2
00815 uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
00816
00838 U_CAPI const char * U_EXPORT2
00839 uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status);
00840
00841
00860 U_CAPI void U_EXPORT2
00861 uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status);
00862
00863
00884 U_CAPI const USet * U_EXPORT2
00885 uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status);
00886
00887
00920 U_CAPI int32_t U_EXPORT2
00921 uspoof_check(const USpoofChecker *sc,
00922 const UChar *id, int32_t length,
00923 int32_t *position,
00924 UErrorCode *status);
00925
00926
00959 U_CAPI int32_t U_EXPORT2
00960 uspoof_checkUTF8(const USpoofChecker *sc,
00961 const char *id, int32_t length,
00962 int32_t *position,
00963 UErrorCode *status);
00964
00965
00994 U_CAPI int32_t U_EXPORT2
00995 uspoof_check2(const USpoofChecker *sc,
00996 const UChar* id, int32_t length,
00997 USpoofCheckResult* checkResult,
00998 UErrorCode *status);
00999
01031 U_CAPI int32_t U_EXPORT2
01032 uspoof_check2UTF8(const USpoofChecker *sc,
01033 const char *id, int32_t length,
01034 USpoofCheckResult* checkResult,
01035 UErrorCode *status);
01036
01055 U_CAPI USpoofCheckResult* U_EXPORT2
01056 uspoof_openCheckResult(UErrorCode *status);
01057
01065 U_CAPI void U_EXPORT2
01066 uspoof_closeCheckResult(USpoofCheckResult *checkResult);
01067
01082 U_CAPI int32_t U_EXPORT2
01083 uspoof_getCheckResultChecks(const USpoofCheckResult *checkResult, UErrorCode *status);
01084
01095 U_CAPI URestrictionLevel U_EXPORT2
01096 uspoof_getCheckResultRestrictionLevel(const USpoofCheckResult *checkResult, UErrorCode *status);
01097
01109 U_CAPI const USet* U_EXPORT2
01110 uspoof_getCheckResultNumerics(const USpoofCheckResult *checkResult, UErrorCode *status);
01111
01112
01156 U_CAPI int32_t U_EXPORT2
01157 uspoof_areConfusable(const USpoofChecker *sc,
01158 const UChar *id1, int32_t length1,
01159 const UChar *id2, int32_t length2,
01160 UErrorCode *status);
01161
01162
01163
01189 U_CAPI int32_t U_EXPORT2
01190 uspoof_areConfusableUTF8(const USpoofChecker *sc,
01191 const char *id1, int32_t length1,
01192 const char *id2, int32_t length2,
01193 UErrorCode *status);
01194
01195
01196
01197
01229 U_CAPI int32_t U_EXPORT2
01230 uspoof_getSkeleton(const USpoofChecker *sc,
01231 uint32_t type,
01232 const UChar *id, int32_t length,
01233 UChar *dest, int32_t destCapacity,
01234 UErrorCode *status);
01235
01269 U_CAPI int32_t U_EXPORT2
01270 uspoof_getSkeletonUTF8(const USpoofChecker *sc,
01271 uint32_t type,
01272 const char *id, int32_t length,
01273 char *dest, int32_t destCapacity,
01274 UErrorCode *status);
01275
01288 U_CAPI const USet * U_EXPORT2
01289 uspoof_getInclusionSet(UErrorCode *status);
01290
01303 U_CAPI const USet * U_EXPORT2
01304 uspoof_getRecommendedSet(UErrorCode *status);
01305
01328 U_CAPI int32_t U_EXPORT2
01329 uspoof_serialize(USpoofChecker *sc,
01330 void *data, int32_t capacity,
01331 UErrorCode *status);
01332
01333 U_CDECL_END
01334
01335 #if U_SHOW_CPLUSPLUS_API
01336
01337 U_NAMESPACE_BEGIN
01338
01353 U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckerPointer, USpoofChecker, uspoof_close);
01371 U_DEFINE_LOCAL_OPEN_POINTER(LocalUSpoofCheckResultPointer, USpoofCheckResult, uspoof_closeCheckResult);
01374 U_NAMESPACE_END
01375
01394 U_CAPI void U_EXPORT2
01395 uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status);
01396
01397
01418 U_CAPI const icu::UnicodeSet * U_EXPORT2
01419 uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status);
01420
01449 U_CAPI int32_t U_EXPORT2
01450 uspoof_checkUnicodeString(const USpoofChecker *sc,
01451 const icu::UnicodeString &id,
01452 int32_t *position,
01453 UErrorCode *status);
01454
01480 U_CAPI int32_t U_EXPORT2
01481 uspoof_check2UnicodeString(const USpoofChecker *sc,
01482 const icu::UnicodeString &id,
01483 USpoofCheckResult* checkResult,
01484 UErrorCode *status);
01485
01507 U_CAPI int32_t U_EXPORT2
01508 uspoof_areConfusableUnicodeString(const USpoofChecker *sc,
01509 const icu::UnicodeString &s1,
01510 const icu::UnicodeString &s2,
01511 UErrorCode *status);
01512
01536 U_I18N_API icu::UnicodeString & U_EXPORT2
01537 uspoof_getSkeletonUnicodeString(const USpoofChecker *sc,
01538 uint32_t type,
01539 const icu::UnicodeString &id,
01540 icu::UnicodeString &dest,
01541 UErrorCode *status);
01542
01555 U_CAPI const icu::UnicodeSet * U_EXPORT2
01556 uspoof_getInclusionUnicodeSet(UErrorCode *status);
01557
01570 U_CAPI const icu::UnicodeSet * U_EXPORT2
01571 uspoof_getRecommendedUnicodeSet(UErrorCode *status);
01572
01573 #endif
01574
01575 #endif
01576
01577 #endif