File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $PostgreSQL: pgsql/src/port/chklocale.c,v 1.1 2007/09/28 22:25:49 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/port/chklocale.c,v 1.2 2007/09/28 23:36:06 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -158,6 +158,7 @@ pg_get_encoding_from_locale(const char *ctype)
158
158
char * sys ;
159
159
int i ;
160
160
161
+ /* Get the CODESET property, and also LC_CTYPE if not passed in */
161
162
if (ctype )
162
163
{
163
164
char * save ;
@@ -197,12 +198,14 @@ pg_get_encoding_from_locale(const char *ctype)
197
198
if (!sys )
198
199
return PG_SQL_ASCII ; /* out of memory; unlikely */
199
200
201
+ /* If locale is C or POSIX, we can allow all encodings */
200
202
if (pg_strcasecmp (ctype , "C" ) == 0 || pg_strcasecmp (ctype , "POSIX" ) == 0 )
201
203
{
202
204
free (sys );
203
205
return PG_SQL_ASCII ;
204
206
}
205
207
208
+ /* Check the table */
206
209
for (i = 0 ; encoding_match_list [i ].system_enc_name ; i ++ )
207
210
{
208
211
if (pg_strcasecmp (sys , encoding_match_list [i ].system_enc_name ) == 0 )
@@ -212,6 +215,20 @@ pg_get_encoding_from_locale(const char *ctype)
212
215
}
213
216
}
214
217
218
+ /* Special-case kluges for particular platforms go here */
219
+
220
+ #ifdef __darwin__
221
+ /*
222
+ * Current OS X has many locales that report an empty string for CODESET,
223
+ * but they all seem to actually use UTF-8.
224
+ */
225
+ if (strlen (sys ) == 0 )
226
+ {
227
+ free (sys );
228
+ return PG_UTF8 ;
229
+ }
230
+ #endif
231
+
215
232
/*
216
233
* We print a warning if we got a CODESET string but couldn't recognize
217
234
* it. This means we need another entry in the table.
You can’t perform that action at this time.
0 commit comments