Skip to content

Commit 7af770d

Browse files
committed
Add Charset WIN1252 support.
Roland Volkmann
1 parent c5bf116 commit 7af770d

File tree

6 files changed

+349
-2
lines changed

6 files changed

+349
-2
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
static pg_utf_to_local ULmapWIN1252[ 124 ] = {
2+
{0x0000, 0x0081},
3+
{0xc2a0, 0x00a0},
4+
{0xc2a1, 0x00a1},
5+
{0xc2a2, 0x00a2},
6+
{0xc2a3, 0x00a3},
7+
{0xc2a4, 0x00a4},
8+
{0xc2a5, 0x00a5},
9+
{0xc2a6, 0x00a6},
10+
{0xc2a7, 0x00a7},
11+
{0xc2a8, 0x00a8},
12+
{0xc2a9, 0x00a9},
13+
{0xc2aa, 0x00aa},
14+
{0xc2ab, 0x00ab},
15+
{0xc2ac, 0x00ac},
16+
{0xc2ad, 0x00ad},
17+
{0xc2ae, 0x00ae},
18+
{0xc2af, 0x00af},
19+
{0xc2b0, 0x00b0},
20+
{0xc2b1, 0x00b1},
21+
{0xc2b2, 0x00b2},
22+
{0xc2b3, 0x00b3},
23+
{0xc2b4, 0x00b4},
24+
{0xc2b5, 0x00b5},
25+
{0xc2b6, 0x00b6},
26+
{0xc2b7, 0x00b7},
27+
{0xc2b8, 0x00b8},
28+
{0xc2b9, 0x00b9},
29+
{0xc2ba, 0x00ba},
30+
{0xc2bb, 0x00bb},
31+
{0xc2bc, 0x00bc},
32+
{0xc2bd, 0x00bd},
33+
{0xc2be, 0x00be},
34+
{0xc2bf, 0x00bf},
35+
{0xc380, 0x00c0},
36+
{0xc381, 0x00c1},
37+
{0xc382, 0x00c2},
38+
{0xc383, 0x00c3},
39+
{0xc384, 0x00c4},
40+
{0xc385, 0x00c5},
41+
{0xc386, 0x00c6},
42+
{0xc387, 0x00c7},
43+
{0xc388, 0x00c8},
44+
{0xc389, 0x00c9},
45+
{0xc38a, 0x00ca},
46+
{0xc38b, 0x00cb},
47+
{0xc38c, 0x00cc},
48+
{0xc38d, 0x00cd},
49+
{0xc38e, 0x00ce},
50+
{0xc38f, 0x00cf},
51+
{0xc390, 0x00d0},
52+
{0xc391, 0x00d1},
53+
{0xc392, 0x00d2},
54+
{0xc393, 0x00d3},
55+
{0xc394, 0x00d4},
56+
{0xc395, 0x00d5},
57+
{0xc396, 0x00d6},
58+
{0xc397, 0x00d7},
59+
{0xc398, 0x00d8},
60+
{0xc399, 0x00d9},
61+
{0xc39a, 0x00da},
62+
{0xc39b, 0x00db},
63+
{0xc39c, 0x00dc},
64+
{0xc39d, 0x00dd},
65+
{0xc39e, 0x00de},
66+
{0xc39f, 0x00df},
67+
{0xc3a0, 0x00e0},
68+
{0xc3a1, 0x00e1},
69+
{0xc3a2, 0x00e2},
70+
{0xc3a3, 0x00e3},
71+
{0xc3a4, 0x00e4},
72+
{0xc3a5, 0x00e5},
73+
{0xc3a6, 0x00e6},
74+
{0xc3a7, 0x00e7},
75+
{0xc3a8, 0x00e8},
76+
{0xc3a9, 0x00e9},
77+
{0xc3aa, 0x00ea},
78+
{0xc3ab, 0x00eb},
79+
{0xc3ac, 0x00ec},
80+
{0xc3ad, 0x00ed},
81+
{0xc3ae, 0x00ee},
82+
{0xc3af, 0x00ef},
83+
{0xc3b0, 0x00f0},
84+
{0xc3b1, 0x00f1},
85+
{0xc3b2, 0x00f2},
86+
{0xc3b3, 0x00f3},
87+
{0xc3b4, 0x00f4},
88+
{0xc3b5, 0x00f5},
89+
{0xc3b6, 0x00f6},
90+
{0xc3b7, 0x00f7},
91+
{0xc3b8, 0x00f8},
92+
{0xc3b9, 0x00f9},
93+
{0xc3ba, 0x00fa},
94+
{0xc3bb, 0x00fb},
95+
{0xc3bc, 0x00fc},
96+
{0xc3bd, 0x00fd},
97+
{0xc3be, 0x00fe},
98+
{0xc3bf, 0x00ff},
99+
{0xc592, 0x008c},
100+
{0xc593, 0x009c},
101+
{0xc5a0, 0x008a},
102+
{0xc5a1, 0x009a},
103+
{0xc5b8, 0x009f},
104+
{0xc5bd, 0x008e},
105+
{0xc5be, 0x009e},
106+
{0xc692, 0x0083},
107+
{0xcb86, 0x0088},
108+
{0xcb9c, 0x0098},
109+
{0xe28093, 0x0096},
110+
{0xe28094, 0x0097},
111+
{0xe28098, 0x0091},
112+
{0xe28099, 0x0092},
113+
{0xe2809a, 0x0082},
114+
{0xe2809c, 0x0093},
115+
{0xe2809d, 0x0094},
116+
{0xe2809e, 0x0084},
117+
{0xe280a0, 0x0086},
118+
{0xe280a1, 0x0087},
119+
{0xe280a2, 0x0095},
120+
{0xe280a6, 0x0085},
121+
{0xe280b0, 0x0089},
122+
{0xe280b9, 0x008b},
123+
{0xe280ba, 0x009b},
124+
{0xe282ac, 0x0080},
125+
{0xe284a2, 0x0099}
126+
};
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
static pg_local_to_utf LUmapWIN1252[ 128 ] = {
2+
{0x0080, 0xe282ac},
3+
{0x0081, 0x0000},
4+
{0x0082, 0xe2809a},
5+
{0x0083, 0xc692},
6+
{0x0084, 0xe2809e},
7+
{0x0085, 0xe280a6},
8+
{0x0086, 0xe280a0},
9+
{0x0087, 0xe280a1},
10+
{0x0088, 0xcb86},
11+
{0x0089, 0xe280b0},
12+
{0x008a, 0xc5a0},
13+
{0x008b, 0xe280b9},
14+
{0x008c, 0xc592},
15+
{0x008d, 0x0000},
16+
{0x008e, 0xc5bd},
17+
{0x008f, 0x0000},
18+
{0x0090, 0x0000},
19+
{0x0091, 0xe28098},
20+
{0x0092, 0xe28099},
21+
{0x0093, 0xe2809c},
22+
{0x0094, 0xe2809d},
23+
{0x0095, 0xe280a2},
24+
{0x0096, 0xe28093},
25+
{0x0097, 0xe28094},
26+
{0x0098, 0xcb9c},
27+
{0x0099, 0xe284a2},
28+
{0x009a, 0xc5a1},
29+
{0x009b, 0xe280ba},
30+
{0x009c, 0xc593},
31+
{0x009d, 0x0000},
32+
{0x009e, 0xc5be},
33+
{0x009f, 0xc5b8},
34+
{0x00a0, 0xc2a0},
35+
{0x00a1, 0xc2a1},
36+
{0x00a2, 0xc2a2},
37+
{0x00a3, 0xc2a3},
38+
{0x00a4, 0xc2a4},
39+
{0x00a5, 0xc2a5},
40+
{0x00a6, 0xc2a6},
41+
{0x00a7, 0xc2a7},
42+
{0x00a8, 0xc2a8},
43+
{0x00a9, 0xc2a9},
44+
{0x00aa, 0xc2aa},
45+
{0x00ab, 0xc2ab},
46+
{0x00ac, 0xc2ac},
47+
{0x00ad, 0xc2ad},
48+
{0x00ae, 0xc2ae},
49+
{0x00af, 0xc2af},
50+
{0x00b0, 0xc2b0},
51+
{0x00b1, 0xc2b1},
52+
{0x00b2, 0xc2b2},
53+
{0x00b3, 0xc2b3},
54+
{0x00b4, 0xc2b4},
55+
{0x00b5, 0xc2b5},
56+
{0x00b6, 0xc2b6},
57+
{0x00b7, 0xc2b7},
58+
{0x00b8, 0xc2b8},
59+
{0x00b9, 0xc2b9},
60+
{0x00ba, 0xc2ba},
61+
{0x00bb, 0xc2bb},
62+
{0x00bc, 0xc2bc},
63+
{0x00bd, 0xc2bd},
64+
{0x00be, 0xc2be},
65+
{0x00bf, 0xc2bf},
66+
{0x00c0, 0xc380},
67+
{0x00c1, 0xc381},
68+
{0x00c2, 0xc382},
69+
{0x00c3, 0xc383},
70+
{0x00c4, 0xc384},
71+
{0x00c5, 0xc385},
72+
{0x00c6, 0xc386},
73+
{0x00c7, 0xc387},
74+
{0x00c8, 0xc388},
75+
{0x00c9, 0xc389},
76+
{0x00ca, 0xc38a},
77+
{0x00cb, 0xc38b},
78+
{0x00cc, 0xc38c},
79+
{0x00cd, 0xc38d},
80+
{0x00ce, 0xc38e},
81+
{0x00cf, 0xc38f},
82+
{0x00d0, 0xc390},
83+
{0x00d1, 0xc391},
84+
{0x00d2, 0xc392},
85+
{0x00d3, 0xc393},
86+
{0x00d4, 0xc394},
87+
{0x00d5, 0xc395},
88+
{0x00d6, 0xc396},
89+
{0x00d7, 0xc397},
90+
{0x00d8, 0xc398},
91+
{0x00d9, 0xc399},
92+
{0x00da, 0xc39a},
93+
{0x00db, 0xc39b},
94+
{0x00dc, 0xc39c},
95+
{0x00dd, 0xc39d},
96+
{0x00de, 0xc39e},
97+
{0x00df, 0xc39f},
98+
{0x00e0, 0xc3a0},
99+
{0x00e1, 0xc3a1},
100+
{0x00e2, 0xc3a2},
101+
{0x00e3, 0xc3a3},
102+
{0x00e4, 0xc3a4},
103+
{0x00e5, 0xc3a5},
104+
{0x00e6, 0xc3a6},
105+
{0x00e7, 0xc3a7},
106+
{0x00e8, 0xc3a8},
107+
{0x00e9, 0xc3a9},
108+
{0x00ea, 0xc3aa},
109+
{0x00eb, 0xc3ab},
110+
{0x00ec, 0xc3ac},
111+
{0x00ed, 0xc3ad},
112+
{0x00ee, 0xc3ae},
113+
{0x00ef, 0xc3af},
114+
{0x00f0, 0xc3b0},
115+
{0x00f1, 0xc3b1},
116+
{0x00f2, 0xc3b2},
117+
{0x00f3, 0xc3b3},
118+
{0x00f4, 0xc3b4},
119+
{0x00f5, 0xc3b5},
120+
{0x00f6, 0xc3b6},
121+
{0x00f7, 0xc3b7},
122+
{0x00f8, 0xc3b8},
123+
{0x00f9, 0xc3b9},
124+
{0x00fa, 0xc3ba},
125+
{0x00fb, 0xc3bb},
126+
{0x00fc, 0xc3bc},
127+
{0x00fd, 0xc3bd},
128+
{0x00fe, 0xc3be},
129+
{0x00ff, 0xc3bf}
130+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#-------------------------------------------------------------------------
2+
#
3+
# $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1252/Makefile,v 1.1 2004/12/02 22:14:37 momjian Exp $
4+
#
5+
#-------------------------------------------------------------------------
6+
subdir = src/backend/utils/mb/conversion_procs/utf8_and_win1252
7+
top_builddir = ../../../../../..
8+
include $(top_builddir)/src/Makefile.global
9+
10+
NAME := utf8_and_win1252
11+
12+
include $(srcdir)/../proc.mk
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* WIN1252 and UTF-8
4+
*
5+
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
6+
* Portions Copyright (c) 1994, Regents of the University of California
7+
*
8+
* IDENTIFICATION
9+
* $PostgreSQL: pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1252/utf8_and_win1252.c,v 1.1 2004/12/02 22:14:37 momjian Exp $
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
14+
#include "postgres.h"
15+
#include "fmgr.h"
16+
#include "mb/pg_wchar.h"
17+
#include "../../Unicode/utf8_to_win1252.map"
18+
#include "../../Unicode/win1252_to_utf8.map"
19+
20+
PG_FUNCTION_INFO_V1(utf_to_win1252);
21+
PG_FUNCTION_INFO_V1(win1252_to_utf);
22+
23+
extern Datum utf_to_win1252(PG_FUNCTION_ARGS);
24+
extern Datum win1252_to_utf(PG_FUNCTION_ARGS);
25+
26+
/* ----------
27+
* conv_proc(
28+
* INTEGER, -- source encoding id
29+
* INTEGER, -- destination encoding id
30+
* CSTRING, -- source string (null terminated C string)
31+
* CSTRING, -- destination string (null terminated C string)
32+
* INTEGER -- source string length
33+
* ) returns VOID;
34+
* ----------
35+
*/
36+
37+
Datum
38+
utf_to_win1252(PG_FUNCTION_ARGS)
39+
{
40+
unsigned char *src = PG_GETARG_CSTRING(2);
41+
unsigned char *dest = PG_GETARG_CSTRING(3);
42+
int len = PG_GETARG_INT32(4);
43+
44+
Assert(PG_GETARG_INT32(0) == PG_UTF8);
45+
Assert(PG_GETARG_INT32(1) == PG_WIN1252);
46+
Assert(len >= 0);
47+
48+
UtfToLocal(src, dest, ULmapWIN1252,
49+
sizeof(ULmapWIN1252) / sizeof(pg_utf_to_local), len);
50+
51+
PG_RETURN_VOID();
52+
}
53+
54+
Datum
55+
win1252_to_utf(PG_FUNCTION_ARGS)
56+
{
57+
unsigned char *src = PG_GETARG_CSTRING(2);
58+
unsigned char *dest = PG_GETARG_CSTRING(3);
59+
int len = PG_GETARG_INT32(4);
60+
61+
Assert(PG_GETARG_INT32(0) == PG_WIN1252);
62+
Assert(PG_GETARG_INT32(1) == PG_UTF8);
63+
Assert(len >= 0);
64+
65+
LocalToUtf(src, dest, LUmapWIN1252,
66+
sizeof(LUmapWIN1252) / sizeof(pg_local_to_utf), PG_WIN1252, len);
67+
68+
PG_RETURN_VOID();
69+
}

src/backend/utils/mb/encnames.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Encoding names and routines for work with it. All
33
* in this file is shared bedween FE and BE.
44
*
5-
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.20 2004/09/27 23:24:33 momjian Exp $
5+
* $PostgreSQL: pgsql/src/backend/utils/mb/encnames.c,v 1.21 2004/12/02 22:14:36 momjian Exp $
66
*/
77
#ifdef FRONTEND
88
#include "postgres_fe.h"
@@ -193,6 +193,9 @@ pg_encname pg_encname_tbl[] =
193193
{
194194
"win1251", PG_WIN1251
195195
}, /* alias for Windows-1251 */
196+
{
197+
"win1252", PG_WIN1252
198+
}, /* alias for Windows-1252 */
196199
{
197200
"win1256", PG_WIN1256
198201
}, /* alias for Windows-1256 */
@@ -220,6 +223,9 @@ pg_encname pg_encname_tbl[] =
220223
{
221224
"windows1251", PG_WIN1251
222225
}, /* Windows-1251; Microsoft */
226+
{
227+
"windows1252", PG_WIN1252
228+
}, /* Windows-1252; Microsoft */
223229
{
224230
"windows1256", PG_WIN1256
225231
}, /* Windows-1256; Microsoft */
@@ -343,6 +349,9 @@ pg_enc2name pg_enc2name_tbl[] =
343349
{
344350
"WIN1250", PG_WIN1250
345351
},
352+
{
353+
"WIN1252", PG_WIN1252
354+
},
346355
{
347356
"SJIS", PG_SJIS
348357
},

src/include/mb/pg_wchar.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.52 2004/09/17 21:59:57 petere Exp $ */
1+
/* $PostgreSQL: pgsql/src/include/mb/pg_wchar.h,v 1.53 2004/12/02 22:14:38 momjian Exp $ */
22

33
#ifndef PG_WCHAR_H
44
#define PG_WCHAR_H
@@ -178,6 +178,7 @@ typedef enum pg_enc
178178
PG_ISO_8859_7, /* ISO-8859-7 */
179179
PG_ISO_8859_8, /* ISO-8859-8 */
180180
PG_WIN1250, /* windows-1250 */
181+
PG_WIN1252, /* windows-1252 */
181182

182183
/* followings are for client encoding only */
183184
PG_SJIS, /* Shift JIS (Winindows-932) */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy