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