Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f32999

Browse files
committed
On OS X, assume that an empty-string result for nl_langinfo(CODESET)
means UTF-8. Per examination of /usr/share/locale in 10.4.10.
1 parent304750f commit1f32999

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎src/port/chklocale.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
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)
158158
char*sys;
159159
inti;
160160

161+
/* Get the CODESET property, and also LC_CTYPE if not passed in */
161162
if (ctype)
162163
{
163164
char*save;
@@ -197,12 +198,14 @@ pg_get_encoding_from_locale(const char *ctype)
197198
if (!sys)
198199
returnPG_SQL_ASCII;/* out of memory; unlikely */
199200

201+
/* If locale is C or POSIX, we can allow all encodings */
200202
if (pg_strcasecmp(ctype,"C")==0||pg_strcasecmp(ctype,"POSIX")==0)
201203
{
202204
free(sys);
203205
returnPG_SQL_ASCII;
204206
}
205207

208+
/* Check the table */
206209
for (i=0;encoding_match_list[i].system_enc_name;i++)
207210
{
208211
if (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+
returnPG_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.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp