pg_locale.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*-----------------------------------------------------------------------
  2. *
  3. * PostgreSQL locale utilities
  4. *
  5. * src/include/utils/pg_locale.h
  6. *
  7. * Copyright (c) 2002-2016, PostgreSQL Global Development Group
  8. *
  9. *-----------------------------------------------------------------------
  10. */
  11. #ifndef _PG_LOCALE_
  12. #define _PG_LOCALE_
  13. #include <locale.h>
  14. #if defined(LOCALE_T_IN_XLOCALE) || defined(WCSTOMBS_L_IN_XLOCALE)
  15. #include <xlocale.h>
  16. #endif
  17. #include "utils/guc.h"
  18. /* GUC settings */
  19. extern char *locale_messages;
  20. extern char *locale_monetary;
  21. extern char *locale_numeric;
  22. extern char *locale_time;
  23. /* lc_time localization cache */
  24. extern char *localized_abbrev_days[];
  25. extern char *localized_full_days[];
  26. extern char *localized_abbrev_months[];
  27. extern char *localized_full_months[];
  28. extern bool check_locale_messages(char **newval, void **extra, GucSource source);
  29. extern void assign_locale_messages(const char *newval, void *extra);
  30. extern bool check_locale_monetary(char **newval, void **extra, GucSource source);
  31. extern void assign_locale_monetary(const char *newval, void *extra);
  32. extern bool check_locale_numeric(char **newval, void **extra, GucSource source);
  33. extern void assign_locale_numeric(const char *newval, void *extra);
  34. extern bool check_locale_time(char **newval, void **extra, GucSource source);
  35. extern void assign_locale_time(const char *newval, void *extra);
  36. extern bool check_locale(int category, const char *locale, char **canonname);
  37. extern char *pg_perm_setlocale(int category, const char *locale);
  38. extern void check_strxfrm_bug(void);
  39. extern bool lc_collate_is_c(Oid collation);
  40. extern bool lc_ctype_is_c(Oid collation);
  41. /*
  42. * Return the POSIX lconv struct (contains number/money formatting
  43. * information) with locale information for all categories.
  44. */
  45. extern struct lconv *PGLC_localeconv(void);
  46. extern void cache_locale_time(void);
  47. /*
  48. * We define our own wrapper around locale_t so we can keep the same
  49. * function signatures for all builds, while not having to create a
  50. * fake version of the standard type locale_t in the global namespace.
  51. * The fake version of pg_locale_t can be checked for truth; that's
  52. * about all it will be needed for.
  53. */
  54. #ifdef HAVE_LOCALE_T
  55. typedef locale_t pg_locale_t;
  56. #else
  57. typedef int pg_locale_t;
  58. #endif
  59. extern pg_locale_t pg_newlocale_from_collation(Oid collid);
  60. /* These functions convert from/to libc's wchar_t, *not* pg_wchar_t */
  61. #ifdef USE_WIDE_UPPER_LOWER
  62. extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen,
  63. pg_locale_t locale);
  64. extern size_t char2wchar(wchar_t *to, size_t tolen,
  65. const char *from, size_t fromlen, pg_locale_t locale);
  66. #endif
  67. #endif /* _PG_LOCALE_ */