88 *
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/port/chklocale.c,v 1.1 2007/09/2822:25:49 tgl Exp $
11+ * $PostgreSQL: pgsql/src/port/chklocale.c,v 1.2 2007/09/2823:36:06 tgl Exp $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -158,6 +158,7 @@ pg_get_encoding_from_locale(const char *ctype)
158158char * sys ;
159159int i ;
160160
161+ /* Get the CODESET property, and also LC_CTYPE if not passed in */
161162if (ctype )
162163{
163164char * save ;
@@ -197,12 +198,14 @@ pg_get_encoding_from_locale(const char *ctype)
197198if (!sys )
198199return PG_SQL_ASCII ;/* out of memory; unlikely */
199200
201+ /* If locale is C or POSIX, we can allow all encodings */
200202if (pg_strcasecmp (ctype ,"C" )== 0 || pg_strcasecmp (ctype ,"POSIX" )== 0 )
201203{
202204free (sys );
203205return PG_SQL_ASCII ;
204206}
205207
208+ /* Check the table */
206209for (i = 0 ;encoding_match_list [i ].system_enc_name ;i ++ )
207210{
208211if (pg_strcasecmp (sys ,encoding_match_list [i ].system_enc_name )== 0 )
@@ -212,6 +215,20 @@ pg_get_encoding_from_locale(const char *ctype)
212215}
213216}
214217
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+
215232/*
216233 * We print a warning if we got a CODESET string but couldn't recognize
217234 * it. This means we need another entry in the table.