37 {0x01, 437,
"U.S. MS-DOS",
"CP437",
""},
38 {0x02, 850,
"International MS-DOS",
"CP850",
""},
39 {0x03, 1252,
"Window ANSI",
"WINDOWS-1252",
"WIN1252"},
40 {0x08, 865,
"Danish OEM",
"CP865",
""},
41 {0x09, 437,
"Dutch OEM",
"CP437",
""},
42 {0x0A, 850,
"Dutch OEM*",
"CP850",
""},
43 {0x0B, 437,
"Finnish OEM",
"CP437",
""},
44 {0x0D, 437,
"French OEM",
"CP437",
""},
45 {0x0E, 850,
"French OEM*",
"CP850",
""},
46 {0x0F, 437,
"German OEM",
"CP437",
""},
47 {0x10, 850,
"German OEM*",
"CP850",
""},
48 {0x11, 437,
"Italian OEM",
"CP437",
""},
49 {0x12, 850,
"Italian OEM*",
"CP850",
""},
50 {0x13, 932,
"Japanese Shift-JIS",
"CP932",
"SJIS"},
51 {0x14, 850,
"Spanish OEM*",
"CP850",
""},
52 {0x15, 437,
"Swedish OEM",
"CP437",
""},
53 {0x16, 850,
"Swedish OEM*",
"CP850",
""},
54 {0x17, 865,
"Norwegian OEM",
"CP865",
""},
55 {0x18, 437,
"Spanish OEM",
"CP865",
""},
56 {0x19, 437,
"English OEM (Britain)",
"CP437",
""},
57 {0x1A, 850,
"English OEM (Britain)*",
"CP850",
""},
58 {0x1B, 437,
"English OEM (U.S.)",
"CP437",
""},
59 {0x1C, 863,
"French OEM (Canada)",
"CP863",
""},
60 {0x1D, 850,
"French OEM*",
"CP850",
""},
61 {0x1F, 852,
"Czech OEM",
"CP852",
""},
62 {0x22, 852,
"Hungarian OEM",
"CP852",
""},
63 {0x23, 852,
"Polish OEM",
"CP852",
""},
64 {0x24, 860,
"Portuguese OEM",
"CP860",
""},
65 {0x25, 850,
"Portuguese OEM*",
"CP850",
""},
66 {0x26, 866,
"Russian OEM",
"WINDOWS-866",
"WIN866"},
67 {0x37, 850,
"English OEM (U.S.)*",
"CP850",
""},
68 {0x40, 852,
"Romanian OEM",
"CP852",
""},
69 {0x4D, 936,
"Chinese GBK (PRC)",
"CP936",
""},
70 {0x4E, 949,
"Korean (ANSI/OEM)",
"CP949",
""},
71 {0x4F, 950,
"Chinese Big 5 (Taiwan)",
"CP950",
"BIG5"},
72 {0x50, 874,
"Thai (ANSI/OEM)",
"WIN874",
""},
73 {0x57, 1252,
"ANSI",
"WINDOWS-1252",
""},
74 {0x58, 1252,
"Western European ANSI",
"WINDOWS-1252",
""},
75 {0x59, 1252,
"Spanish ANSI",
"WINDOWS-1252",
""},
76 {0x64, 852,
"Eastern European MS-DOS",
"CP852",
""},
77 {0x65, 866,
"Russian MS-DOS",
"CP866",
""},
78 {0x66, 865,
"Nordic MS-DOS",
"CP865",
""},
79 {0x67, 861,
"Icelandic MS-DOS",
"",
""},
80 {0x6A, 737,
"Greek MS-DOS (437G)",
"CP737",
""},
81 {0x6B, 857,
"Turkish MS-DOS",
"CP857",
""},
82 {0x6C, 863,
"French-Canadian MS-DOS",
"CP863",
""},
83 {0x78, 950,
"Taiwan Big 5",
"CP950",
""},
84 {0x79, 949,
"Hangul (Wansung)",
"CP949",
""},
85 {0x7A, 936,
"PRC GBK",
"CP936",
"GBK"},
86 {0x7B, 932,
"Japanese Shift-JIS",
"CP932",
""},
87 {0x7C, 874,
"Thai Windows/MS-DOS",
"WINDOWS-874",
"WIN874"},
88 {0x86, 737,
"Greek OEM",
"CP737",
""},
89 {0x87, 852,
"Slovenian OEM",
"CP852",
""},
90 {0x88, 857,
"Turkish OEM",
"CP857",
""},
91 {0xC8, 1250,
"Eastern European Windows",
"WINDOWS-1250",
"WIN1250"},
92 {0xC9, 1251,
"Russian Windows",
"WINDOWS-1251",
"WIN1251"},
93 {0xCA, 1254,
"Turkish Windows",
"WINDOWS-1254",
"WIN1254"},
94 {0xCB, 1253,
"Greek Windows",
"WINDOWS-1253",
"WIN1253"},
95 {0xCC, 1257,
"Baltic Window",
"WINDOWS-1257",
"WIN1257"},
96 {0xFF, 65001,
"UTF-8",
"UTF-8",
"UTF8"}
130 if (*ptr ==
'\'' || *ptr ==
'\\')
140 size = ptr - str + toescape + 1;
141 result = calloc(1, size);
147 if (*ptr ==
'\'' || *ptr ==
'\\')
173 for (i = 0; i < map->
size; i++)
188 for (i=0; i<map->
size; i++)
202 for (i=0; i<map->
size; i++)
216 char linebuffer[1024];
218 int curmapsize, fieldnamesize;
222 fptr = fopen(filename,
"r");
226 snprintf(errbuf, errbuflen,
_(
"ERROR: Unable to open column map file %s"),
232 while (fgets(linebuffer, 1024, fptr) != NULL) ++map->
size;
235 fseek(fptr, 0, SEEK_SET);
241 while (fgets(linebuffer, 1024, fptr) != NULL)
245 fieldnamesize = strcspn(linebuffer,
"\t\n ");
250 strncpy(map->
pgfieldnames[curmapsize], tmpstr, fieldnamesize);
254 tmpstr = linebuffer + fieldnamesize;
255 tmpstr += strspn(tmpstr,
"\t\n ");
258 fieldnamesize = strcspn(tmpstr,
"\t\n ");
262 strncpy(map->
dbffieldnames[curmapsize], tmpstr, fieldnamesize);
268 snprintf(errbuf, errbuflen,
_(
"ERROR: column map file specifies a DBF field name \"%s\" which is longer than 10 characters"), map->
dbffieldnames[curmapsize]);
295 if ( ! cpg )
return NULL;
299 cpglen = strlen(cpg);
300 if ( strstr(cpg,
"LDID/") )
348 if ( strcasecmp(encoding,
code_pages[i].pg) == 0 )
352 return strdup(
"UTF-8");
356 char *codepage = NULL;
357 int ret = asprintf(&codepage,
"LDID/%d",
code_pages[i].ldid);
358 if ( ret == -1 )
return NULL;
365 return strdup(
"UTF-8");
char * encoding2codepage(const char *encoding)
char * escape_connection_string(char *str)
Escape strings that are to be used as part of a PostgreSQL connection string.
static int num_code_pages
static code_page_entry code_pages[]
int colmap_read(const char *filename, colmap *map, char *errbuf, size_t errbuflen)
Read the content of filename into a symbol map.
void colmap_init(colmap *map)
const char * colmap_dbf_by_pg(colmap *map, const char *pgname)
const char * colmap_pg_by_dbf(colmap *map, const char *dbfname)
void colmap_clean(colmap *map)
char * codepage2encoding(const char *cpg)