gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.4KB

  1. /*-----------------------------------------------------------------------
  2. *
  3. * PostgreSQL locale utilities
  4. *
  5. * src/include/utils/pg_locale.h
  6. *
  7. * Copyright (c) 2002-2019, PostgreSQL Global Development Group
  8. *
  9. *-----------------------------------------------------------------------
  10. */
  11. #ifndef _PG_LOCALE_
  12. #define _PG_LOCALE_
  13. #if defined(LOCALE_T_IN_XLOCALE) || defined(WCSTOMBS_L_IN_XLOCALE)
  14. #include <xlocale.h>
  15. #endif
  16. #ifdef USE_ICU
  17. #include <unicode/ucol.h>
  18. #endif
  19. #include "utils/guc.h"
  20. #ifdef USE_ICU
  21. /*
  22. * ucol_strcollUTF8() was introduced in ICU 50, but it is buggy before ICU 53.
  23. * (see
  24. * <https://www.postgresql.org/message-id/flat/f1438ec6-22aa-4029-9a3b-26f79d330e72%40manitou-mail.org>)
  25. */
  26. #if U_ICU_VERSION_MAJOR_NUM >= 53
  27. #define HAVE_UCOL_STRCOLLUTF8 1
  28. #else
  29. #undef HAVE_UCOL_STRCOLLUTF8
  30. #endif
  31. #endif
  32. /* GUC settings */
  33. extern char *locale_messages;
  34. extern char *locale_monetary;
  35. extern char *locale_numeric;
  36. extern char *locale_time;
  37. /* lc_time localization cache */
  38. extern char *localized_abbrev_days[];
  39. extern char *localized_full_days[];
  40. extern char *localized_abbrev_months[];
  41. extern char *localized_full_months[];
  42. extern bool check_locale_messages(char **newval, void **extra, GucSource source);
  43. extern void assign_locale_messages(const char *newval, void *extra);
  44. extern bool check_locale_monetary(char **newval, void **extra, GucSource source);
  45. extern void assign_locale_monetary(const char *newval, void *extra);
  46. extern bool check_locale_numeric(char **newval, void **extra, GucSource source);
  47. extern void assign_locale_numeric(const char *newval, void *extra);
  48. extern bool check_locale_time(char **newval, void **extra, GucSource source);
  49. extern void assign_locale_time(const char *newval, void *extra);
  50. extern bool check_locale(int category, const char *locale, char **canonname);
  51. extern char *pg_perm_setlocale(int category, const char *locale);
  52. extern void check_strxfrm_bug(void);
  53. extern bool lc_collate_is_c(Oid collation);
  54. extern bool lc_ctype_is_c(Oid collation);
  55. /*
  56. * Return the POSIX lconv struct (contains number/money formatting
  57. * information) with locale information for all categories.
  58. */
  59. extern struct lconv *PGLC_localeconv(void);
  60. extern void cache_locale_time(void);
  61. /*
  62. * We define our own wrapper around locale_t so we can keep the same
  63. * function signatures for all builds, while not having to create a
  64. * fake version of the standard type locale_t in the global namespace.
  65. * pg_locale_t is occasionally checked for truth, so make it a pointer.
  66. */
  67. struct pg_locale_struct
  68. {
  69. char provider;
  70. bool deterministic;
  71. union
  72. {
  73. #ifdef HAVE_LOCALE_T
  74. locale_t lt;
  75. #endif
  76. #ifdef USE_ICU
  77. struct
  78. {
  79. const char *locale;
  80. UCollator *ucol;
  81. } icu;
  82. #endif
  83. int dummy; /* in case we have neither LOCALE_T nor ICU */
  84. } info;
  85. };
  86. typedef struct pg_locale_struct *pg_locale_t;
  87. extern pg_locale_t pg_newlocale_from_collation(Oid collid);
  88. extern char *get_collation_actual_version(char collprovider, const char *collcollate);
  89. #ifdef USE_ICU
  90. extern int32_t icu_to_uchar(UChar **buff_uchar, const char *buff, size_t nbytes);
  91. extern int32_t icu_from_uchar(char **result, const UChar *buff_uchar, int32_t len_uchar);
  92. #endif
  93. /* These functions convert from/to libc's wchar_t, *not* pg_wchar_t */
  94. extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen,
  95. pg_locale_t locale);
  96. extern size_t char2wchar(wchar_t *to, size_t tolen,
  97. const char *from, size_t fromlen, pg_locale_t locale);
  98. #endif /* _PG_LOCALE_ */
上海开阖软件有限公司 沪ICP备12045867号-1