Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
5841aa86
Commit
5841aa86
authored
Jan 22, 2009
by
Magnus Hagander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly bind gettext to the correct encoding on Windows.
Original patch from Hiroshi Inoue.
parent
95aaf25f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
16 deletions
+57
-16
src/backend/utils/mb/mbutils.c
src/backend/utils/mb/mbutils.c
+57
-16
No files found.
src/backend/utils/mb/mbutils.c
View file @
5841aa86
...
...
@@ -4,7 +4,7 @@
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
*
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.7
7 2009/01/19 15:34:23
mha Exp $
* $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.7
8 2009/01/22 10:09:48
mha Exp $
*/
#include "postgres.h"
...
...
@@ -849,6 +849,46 @@ cliplen(const char *str, int len, int limit)
return
l
;
}
#if defined(ENABLE_NLS) && defined(WIN32)
static
const
struct
codeset_map
{
int
encoding
;
const
char
*
codeset
;
}
codeset_map_array
[]
=
{
{
PG_UTF8
,
"UTF-8"
},
{
PG_LATIN1
,
"LATIN1"
},
{
PG_LATIN2
,
"LATIN2"
},
{
PG_LATIN3
,
"LATIN3"
},
{
PG_LATIN4
,
"LATIN4"
},
{
PG_ISO_8859_5
,
"ISO-8859-5"
},
{
PG_ISO_8859_6
,
"ISO_8859-6"
},
{
PG_ISO_8859_7
,
"ISO-8859-7"
},
{
PG_ISO_8859_8
,
"ISO-8859-8"
},
{
PG_LATIN5
,
"LATIN5"
},
{
PG_LATIN6
,
"LATIN6"
},
{
PG_LATIN7
,
"LATIN7"
},
{
PG_LATIN8
,
"LATIN8"
},
{
PG_LATIN9
,
"LATIN-9"
},
{
PG_LATIN10
,
"LATIN10"
},
{
PG_KOI8R
,
"KOI8-R"
},
{
PG_WIN1250
,
"CP1250"
},
{
PG_WIN1251
,
"CP1251"
},
{
PG_WIN1252
,
"CP1252"
},
{
PG_WIN1253
,
"CP1253"
},
{
PG_WIN1254
,
"CP1254"
},
{
PG_WIN1255
,
"CP1255"
},
{
PG_WIN1256
,
"CP1256"
},
{
PG_WIN1257
,
"CP1257"
},
{
PG_WIN1258
,
"CP1258"
},
{
PG_WIN866
,
"CP866"
},
{
PG_WIN874
,
"CP874"
},
{
PG_EUC_CN
,
"EUC-CN"
},
{
PG_EUC_JP
,
"EUC-JP"
},
{
PG_EUC_KR
,
"EUC-KR"
},
{
PG_EUC_TW
,
"EUC-TW"
},
{
PG_EUC_JIS_2004
,
"EUC-JP"
}
};
#endif
/* WIN32 */
void
SetDatabaseEncoding
(
int
encoding
)
{
...
...
@@ -859,22 +899,23 @@ SetDatabaseEncoding(int encoding)
Assert
(
DatabaseEncoding
->
encoding
==
encoding
);
/*
* On Windows, we allow UTF-8 database encoding to be used with any
* locale setting, because UTF-8 requires special handling anyway.
* But this means that gettext() might be misled about what output
* encoding it should use, so we have to tell it explicitly.
*
* In future we might want to call bind_textdomain_codeset
* unconditionally, but that requires knowing how to spell the codeset
* name properly for all encodings on all platforms, which might be
* problematic.
*
* This is presently unnecessary, but harmless, on non-Windows platforms.
* On Windows, we need to explicitly bind gettext to the correct
* encoding, because gettext() tends to get confused.
*/
#ifdef ENABLE_NLS
if
(
encoding
==
PG_UTF8
)
if
(
bind_textdomain_codeset
(
textdomain
(
NULL
),
"UTF-8"
)
==
NULL
)
elog
(
LOG
,
"bind_textdomain_codeset failed"
);
#if defined(ENABLE_NLS) && defined(WIN32)
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
codeset_map_array
)
/
sizeof
(
codeset_map_array
[
0
]);
i
++
)
{
if
(
codeset_map_array
[
i
].
encoding
==
encoding
)
{
if
(
bind_textdomain_codeset
(
textdomain
(
NULL
),
codeset_map_array
[
i
].
codeset
)
==
NULL
)
elog
(
LOG
,
"bind_textdomain_codeset failed"
);
break
;
}
}
}
#endif
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment