diff options
author | Dirk Engling <erdgeist@erdgeist.org> | 2014-02-23 03:25:07 +0100 |
---|---|---|
committer | Dirk Engling <erdgeist@erdgeist.org> | 2014-02-23 03:25:07 +0100 |
commit | 7663bfdd80c1ea8f4e65d72b2780e893ed0282b2 (patch) | |
tree | 1975c022fbe9b15119fc642c678446932ac58df2 /src/export | |
parent | 6e1be3cbdd520994cd911a0d9c75a0c49b958d53 (diff) |
Convert everything to iso8859-1 before output
Diffstat (limited to 'src/export')
-rw-r--r-- | src/export/extract_version_1.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/export/extract_version_1.c b/src/export/extract_version_1.c index 0d45a7d..a739116 100644 --- a/src/export/extract_version_1.c +++ b/src/export/extract_version_1.c | |||
@@ -15,6 +15,23 @@ static char xlat_table[] = { | |||
15 | 0xfb, 0xf9, 0xff, 0xd6, 0xdc, 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xdf, 0x5b, 0x5c, 0x5d, 0x60 | 15 | 0xfb, 0xf9, 0xff, 0xd6, 0xdc, 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xdf, 0x5b, 0x5c, 0x5d, 0x60 |
16 | }; | 16 | }; |
17 | 17 | ||
18 | static char cp437_to_iso8859_1_table[] = { | ||
19 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | ||
20 | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, | ||
21 | 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, | ||
22 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, | ||
23 | 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, | ||
24 | 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, | ||
25 | 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, | ||
26 | 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, | ||
27 | 0xc7, 0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7, 0xea, 0xeb, 0xe8, 0xef, 0xee, 0xec, 0xc4, 0xc5, | ||
28 | 0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9, 0xff, 0xd6, 0xdc, 0xa2, 0xa3, 0xa5, 0x2e, 0x2e, | ||
29 | 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba, 0xbf, 0x2e, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb, | ||
30 | 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, | ||
31 | 0x2e, 0xdf, 0x2e, 0x2e, 0x2e, 0x2e, 0xb5, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, | ||
32 | 0x2e, 0xb1, 0x2e, 0x2e, 0x2e, 0x2e, 0xf7, 0x2e, 0xb0, 0x2e, 0xb7, 0x2e, 0x2e, 0xb2, 0x2e, 0xa0 | ||
33 | }; | ||
34 | |||
18 | void decode_7bit_string( uint8_t const *source, uint8_t *dest ) | 35 | void decode_7bit_string( uint8_t const *source, uint8_t *dest ) |
19 | { | 36 | { |
20 | uint16_t acc = 0, acc_bits = 0; | 37 | uint16_t acc = 0, acc_bits = 0; |
@@ -27,7 +44,6 @@ again: | |||
27 | if( acc_bits == 7 ) { acc_bits = 0; goto again; } | 44 | if( acc_bits == 7 ) { acc_bits = 0; goto again; } |
28 | } | 45 | } |
29 | } | 46 | } |
30 | int fromhex( uint8_t a ) { if(a >='0'&&a<='9')return a-'0';if(a>='a'&&a<='f') return 10+a-'a'; if(a>='A'&&a<='F') return 10+a-'A'; exit(1); } | ||
31 | 47 | ||
32 | void act_on_record( uint8_t *file, int flag, uint8_t *page, uint16_t record_off ) | 48 | void act_on_record( uint8_t *file, int flag, uint8_t *page, uint16_t record_off ) |
33 | { | 49 | { |
@@ -86,8 +102,10 @@ void act_on_file( uint8_t *file, size_t len ) | |||
86 | char *ort = gasse + 1 + strlen(gasse); | 102 | char *ort = gasse + 1 + strlen(gasse); |
87 | char *zip = ort + 1 + strlen(ort); | 103 | char *zip = ort + 1 + strlen(ort); |
88 | char *vorwahl = zip + 1 + strlen(zip); | 104 | char *vorwahl = zip + 1 + strlen(zip); |
105 | char ort_conv[1024]; int i; | ||
89 | 106 | ||
90 | /* printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort, vorwahl ); */ | 107 | for(i=0; ort[i]; ++i ) ort_conv[i] = cp437_to_iso8859_1_table[((uint8_t*)ort)[i]]; ort_conv[i] = 0; |
108 | /* printf( "Working on a %04d page and %06d records file, city: %4s %-32s with prefix %s\n", num_pages, num_records, zip, ort_conv, vorwahl ); */ | ||
91 | 109 | ||
92 | for( page = 0; page < num_pages; ++page ) | 110 | for( page = 0; page < num_pages; ++page ) |
93 | act_on_page( file, file + 0x800 + 0x2000 * page, page ); | 111 | act_on_page( file, file + 0x800 + 0x2000 * page, page ); |