ustringutil.h 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef ustringutil_INCLUDED
  18. #define ustringutil_INCLUDED
  19. #include <kopano/zcdefs.h>
  20. #include <kopano/kcodes.h>
  21. #include <string>
  22. #include <unicode/coll.h>
  23. #include <unicode/sortkey.h>
  24. namespace KC {
  25. typedef Locale ECLocale;
  26. typedef CollationKey ECSortKey;
  27. // us-ascii strings
  28. extern _kc_export const char *str_ifind(const char *haystack, const char *needle);
  29. // Current locale strings
  30. extern _kc_export bool str_equals(const char *, const char *, const ECLocale &);
  31. extern _kc_export bool str_iequals(const char *, const char *, const ECLocale &);
  32. extern _kc_export bool str_startswith(const char *, const char *, const ECLocale &);
  33. extern _kc_export bool str_istartswith(const char *, const char *, const ECLocale &);
  34. extern _kc_export int str_icompare(const char *, const char *, const ECLocale &);
  35. extern _kc_export bool str_contains(const char *haystack, const char *needle, const ECLocale &);
  36. extern _kc_export bool str_icontains(const char *haystack, const char *needle, const ECLocale &);
  37. // Wide character strings
  38. extern _kc_export bool wcs_equals(const wchar_t *s1, const wchar_t *s2, const ECLocale &locale);
  39. extern _kc_export bool wcs_iequals(const wchar_t *, const wchar_t *, const ECLocale &);
  40. extern _kc_export bool wcs_startswith(const wchar_t *, const wchar_t *, const ECLocale &);
  41. extern _kc_export bool wcs_istartswith(const wchar_t *, const wchar_t *, const ECLocale &);
  42. extern _kc_export int wcs_icompare(const wchar_t *, const wchar_t *, const ECLocale &);
  43. extern _kc_export bool wcs_contains(const wchar_t *haystack, const wchar_t *needle, const ECLocale &);
  44. extern _kc_export bool wcs_icontains(const wchar_t *haystack, const wchar_t *needle, const ECLocale &);
  45. // UTF-8 strings
  46. extern _kc_export bool u8_equals(const char *, const char *, const ECLocale &);
  47. extern _kc_export bool u8_iequals(const char *, const char *, const ECLocale &);
  48. extern _kc_export bool u8_startswith(const char *, const char *, const ECLocale &);
  49. extern _kc_export bool u8_istartswith(const char *, const char *, const ECLocale &);
  50. extern _kc_export int u8_icompare(const char *, const char *, const ECLocale &);
  51. extern _kc_export bool u8_contains(const char *haystack, const char *needle, const ECLocale &);
  52. extern _kc_export bool u8_icontains(const char *haystack, const char *needle, const ECLocale &);
  53. extern _kc_export unsigned int u8_ncpy(const char *src, unsigned int n, std::string *dst);
  54. extern _kc_export unsigned int u8_cappedbytes(const char *s, unsigned int max);
  55. extern _kc_export unsigned int u8_len(const char *);
  56. extern _kc_export ECLocale createLocaleFromName(const char *);
  57. extern _kc_export ECRESULT LocaleIdToLCID(const char *locale, ULONG *id);
  58. extern _kc_export ECRESULT LCIDToLocaleId(ULONG id, const char **locale);
  59. extern _kc_export void createSortKeyDataFromUTF8(const char *s, int ncap, const ECLocale &, unsigned int *keysize, unsigned char **key);
  60. extern _kc_export ECSortKey createSortKeyFromUTF8(const char *s, int ncap, const ECLocale &);
  61. extern _kc_export int compareSortKeys(unsigned int nkey1, const unsigned char *key1, unsigned int nkey2, const unsigned char *key2);
  62. extern _kc_export void createSortKeyData(const char *s, int ncap, const ECLocale &, unsigned int *keysize, unsigned char **key);
  63. extern _kc_export void createSortKeyData(const wchar_t *s, int ncap, const ECLocale &, unsigned int *keysize, unsigned char **key);
  64. } /* namespace */
  65. #endif // ndef ustringutil_INCLUDED