Having a file of codepage MacRoman how to read it?

Posted by goo on 30-May-2018 03:52

We get some files With codepage MacRoman, how can we convert them to either utf-8 or iso8859-1 ? 

,Net?

Posted by Riverside Software on 30-May-2018 06:32

Dug this file from an old project, I don't remember anymore how to include it directly in OE, but I'm sure that was easy.

Gilles

CODEPAGE

CODEPAGE-NAME "MACROMAN"

TYPE "1"

ISALPHA

 /*000-015*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

 /*016-031*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

 /*032-047*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

 /*048-063*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

 /*064-079*/  000 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001

 /*080-095*/  001 001 001 001 001 001 001 001 001 001 001 000 000 000 000 000

 /*096-111*/  000 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001

 /*112-127*/  001 001 001 001 001 001 001 001 001 001 001 000 000 000 000 000

 /*128-143*/  001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001

 /*144-159*/  001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001

 /*160-175*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 001 001

 /*176-191*/  000 000 000 000 000 000 000 000 000 001 000 000 000 001 001 001

 /*192-207*/  000 000 000 000 001 000 000 000 000 000 000 001 001 001 001 001

 /*208-223*/  000 000 000 000 000 000 000 000 001 001 000 000 000 000 000 000

 /*224-239*/  000 000 000 000 000 001 001 001 001 001 001 001 001 001 001 001

 /*240-255*/  000 001 001 001 001 000 000 000 000 000 000 000 000 000 000 000

ENDTABLE

ENDCODEPAGE

CASE

CODEPAGE-NAME MACROMAN

CASETABLE-NAME BASIC

TYPE 1

UPPERCASE-MAP

 /*000-015*/  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015

 /*016-031*/  016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031

 /*032-047*/  032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047

 /*048-063*/  048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063

 /*064-079*/  064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079

 /*080-095*/  080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095

 /*096-111*/  096 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079

 /*112-127*/  080 081 082 083 084 085 086 087 088 089 090 123 124 125 126 127

 /*128-143*/  128 129 130 131 132 133 134 231 203 229 128 204 129 130 131 233

 /*144-159*/  230 232 234 237 235 236 132 238 241 239 133 205 242 244 243 134

 /*160-175*/  160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175

 /*176-191*/  176 177 178 179 180 181 182 183 184 185 186 187 188 189 174 175

 /*192-207*/  192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 206

 /*208-223*/  208 209 210 211 212 213 214 215 217 217 218 219 220 221 222 223

 /*224-239*/  224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239

 /*240-255*/  240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

ENDTABLE

LOWERCASE-MAP

 /*000-015*/  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015

 /*016-031*/  016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031

 /*032-047*/  032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047

 /*048-063*/  048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063

 /*064-079*/  064 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111

 /*080-095*/  112 113 114 115 116 117 118 119 120 121 122 091 092 093 094 095

 /*096-111*/  096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111

 /*112-127*/  112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

 /*128-143*/  138 140 141 142 150 154 159 135 136 137 138 139 140 141 142 143

 /*144-159*/  144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

 /*160-175*/  160 161 162 163 164 165 166 167 168 169 170 171 172 173 190 191

 /*176-191*/  176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191

 /*192-207*/  192 193 194 195 196 197 198 199 200 201 202 136 139 155 207 207

 /*208-223*/  208 209 210 211 212 213 214 215 216 216 218 219 220 221 222 223

 /*224-239*/  224 225 226 227 228 137 144 135 145 143 146 148 149 147 151 153

 /*240-255*/  240 152 156 158 157 245 246 247 248 249 250 251 252 253 254 255

ENDTABLE

ENDCASE

#---------------------------------------------------------------------------

#  This table creates an entry for conversion from MacRoman to unicode UTF-8.

CONVERT

SOURCE-NAME "MACROMAN"

TARGET-NAME "UTF-8"

TYPE "19"

 /*000-015*/  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015

 /*016-031*/  016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031

 /*032-047*/  032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047

 /*048-063*/  048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063

 /*064-079*/  064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079

 /*080-095*/  080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095

 /*096-111*/  096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111

 /*112-127*/  112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

 /*128-143*/  0x00C4 0x00C5 0x00C7 0x00C9 0x00D1 0x00D6 0x00DC 0x00E1 0x00E0 0x00E2 0x00E4 0x00E3 0x00E5 0x00E7 0x00E9 0x00E8

 /*144-159*/  0x00EA 0x00EB 0x00ED 0x00EC 0x00EE 0x00EF 0x00F1 0x00F3 0x00F2 0x00F4 0x00F6 0x00F5 0x00FA 0x00F9 0x00FB 0x00FC

 /*160-175*/  0x2020 0x00B0 0x00A2 0x00A3 0x00A7 0x2022 0x00B6 0x00DF 0x00AE 0x00A9 0x2122 0x00B4 0x00A8 0x2260 0x00C6 0x00D8

 /*176-191*/  0x221E 0x00B1 0x2264 0x2265 0x00A5 0x00B5 0x2202 0x2211 0x220F 0x03C0 0x222B 0x00AA 0x00BA 0x03A9 0x00E6 0x00F8

 /*192-207*/  0x00BF 0x00A1 0x00AC 0x221A 0x0192 0x2248 0x2206 0x00AB 0x00BB 0x2026 0x00A0 0x00C0 0x00C3 0x00D5 0x0152 0x0153

 /*208-223*/  0x2013 0x2014 0x201C 0x201D 0x2018 0x2019 0x00F7 0x25CA 0x00FF 0x0178 0x2044 0x20AC 0x2039 0x203A 0xFB01 0xFB02

 /*224-239*/  0x2021 0x00B7 0x201A 0x201E 0x2030 0x00C2 0x00CA 0x00C1 0x00CB 0x00C8 0x00CD 0x00CE 0x00CF 0x00CC 0x00D3 0x00D4

 /*240-255*/  0xF8FF 0x00D2 0x00DA 0x00DB 0x00D9 0x0131 0x02C6 0x02DC 0x00AF 0x02D8 0x02D9 0x02DA 0x00B8 0x02DD 0x02DB 0x02C7

ENDTABLE

ENDCONVERT

All Replies

Posted by goo on 30-May-2018 03:56

One solution is to read the file byte for byte, and convert the byte to correct type.... but….

We get files from several users With different OS, so we do not know what format files comes With.

Posted by JonathanWilson on 30-May-2018 04:45

If this is just a one off file download Notepad++ and save as UTF-8.  

If it's a feed you'd be better asking them to provided it in UTF8.  Or if that's not an option, then en.wikipedia.org/.../Iconv  is a Unix tool, but I'd guess someone will have ported it to Windows

Posted by Torben on 30-May-2018 04:59

You really need to know code-page of files being read in. Reading files with wrong code-page can potentially corrupt your DB indices. (Not able to edit or delete record)

Recommendation is to ask to have those writing the file, doing so in known code-page, fx UTF-8

Alternative is to ask them to generate XML or JSON files, that both defaults to UTF-8

If it is a supported code-page you can add it to input from statement with CONVERT

Posted by goo on 30-May-2018 05:16

I am not able to have the users that saves excel  to a csv file, to be sure it is in an known format. For them, saving the file to a .csv is close to too much to ask for.
 
We have a solution we can stay with, by reading bytes for bytes…
 
//Geir Otto
 

Posted by Riverside Software on 30-May-2018 06:32

Dug this file from an old project, I don't remember anymore how to include it directly in OE, but I'm sure that was easy.

Gilles

CODEPAGE

CODEPAGE-NAME "MACROMAN"

TYPE "1"

ISALPHA

 /*000-015*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

 /*016-031*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

 /*032-047*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

 /*048-063*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 000 000

 /*064-079*/  000 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001

 /*080-095*/  001 001 001 001 001 001 001 001 001 001 001 000 000 000 000 000

 /*096-111*/  000 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001

 /*112-127*/  001 001 001 001 001 001 001 001 001 001 001 000 000 000 000 000

 /*128-143*/  001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001

 /*144-159*/  001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001

 /*160-175*/  000 000 000 000 000 000 000 000 000 000 000 000 000 000 001 001

 /*176-191*/  000 000 000 000 000 000 000 000 000 001 000 000 000 001 001 001

 /*192-207*/  000 000 000 000 001 000 000 000 000 000 000 001 001 001 001 001

 /*208-223*/  000 000 000 000 000 000 000 000 001 001 000 000 000 000 000 000

 /*224-239*/  000 000 000 000 000 001 001 001 001 001 001 001 001 001 001 001

 /*240-255*/  000 001 001 001 001 000 000 000 000 000 000 000 000 000 000 000

ENDTABLE

ENDCODEPAGE

CASE

CODEPAGE-NAME MACROMAN

CASETABLE-NAME BASIC

TYPE 1

UPPERCASE-MAP

 /*000-015*/  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015

 /*016-031*/  016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031

 /*032-047*/  032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047

 /*048-063*/  048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063

 /*064-079*/  064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079

 /*080-095*/  080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095

 /*096-111*/  096 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079

 /*112-127*/  080 081 082 083 084 085 086 087 088 089 090 123 124 125 126 127

 /*128-143*/  128 129 130 131 132 133 134 231 203 229 128 204 129 130 131 233

 /*144-159*/  230 232 234 237 235 236 132 238 241 239 133 205 242 244 243 134

 /*160-175*/  160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175

 /*176-191*/  176 177 178 179 180 181 182 183 184 185 186 187 188 189 174 175

 /*192-207*/  192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 206

 /*208-223*/  208 209 210 211 212 213 214 215 217 217 218 219 220 221 222 223

 /*224-239*/  224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239

 /*240-255*/  240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

ENDTABLE

LOWERCASE-MAP

 /*000-015*/  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015

 /*016-031*/  016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031

 /*032-047*/  032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047

 /*048-063*/  048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063

 /*064-079*/  064 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111

 /*080-095*/  112 113 114 115 116 117 118 119 120 121 122 091 092 093 094 095

 /*096-111*/  096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111

 /*112-127*/  112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

 /*128-143*/  138 140 141 142 150 154 159 135 136 137 138 139 140 141 142 143

 /*144-159*/  144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

 /*160-175*/  160 161 162 163 164 165 166 167 168 169 170 171 172 173 190 191

 /*176-191*/  176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191

 /*192-207*/  192 193 194 195 196 197 198 199 200 201 202 136 139 155 207 207

 /*208-223*/  208 209 210 211 212 213 214 215 216 216 218 219 220 221 222 223

 /*224-239*/  224 225 226 227 228 137 144 135 145 143 146 148 149 147 151 153

 /*240-255*/  240 152 156 158 157 245 246 247 248 249 250 251 252 253 254 255

ENDTABLE

ENDCASE

#---------------------------------------------------------------------------

#  This table creates an entry for conversion from MacRoman to unicode UTF-8.

CONVERT

SOURCE-NAME "MACROMAN"

TARGET-NAME "UTF-8"

TYPE "19"

 /*000-015*/  000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015

 /*016-031*/  016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031

 /*032-047*/  032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047

 /*048-063*/  048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063

 /*064-079*/  064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079

 /*080-095*/  080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095

 /*096-111*/  096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111

 /*112-127*/  112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127

 /*128-143*/  0x00C4 0x00C5 0x00C7 0x00C9 0x00D1 0x00D6 0x00DC 0x00E1 0x00E0 0x00E2 0x00E4 0x00E3 0x00E5 0x00E7 0x00E9 0x00E8

 /*144-159*/  0x00EA 0x00EB 0x00ED 0x00EC 0x00EE 0x00EF 0x00F1 0x00F3 0x00F2 0x00F4 0x00F6 0x00F5 0x00FA 0x00F9 0x00FB 0x00FC

 /*160-175*/  0x2020 0x00B0 0x00A2 0x00A3 0x00A7 0x2022 0x00B6 0x00DF 0x00AE 0x00A9 0x2122 0x00B4 0x00A8 0x2260 0x00C6 0x00D8

 /*176-191*/  0x221E 0x00B1 0x2264 0x2265 0x00A5 0x00B5 0x2202 0x2211 0x220F 0x03C0 0x222B 0x00AA 0x00BA 0x03A9 0x00E6 0x00F8

 /*192-207*/  0x00BF 0x00A1 0x00AC 0x221A 0x0192 0x2248 0x2206 0x00AB 0x00BB 0x2026 0x00A0 0x00C0 0x00C3 0x00D5 0x0152 0x0153

 /*208-223*/  0x2013 0x2014 0x201C 0x201D 0x2018 0x2019 0x00F7 0x25CA 0x00FF 0x0178 0x2044 0x20AC 0x2039 0x203A 0xFB01 0xFB02

 /*224-239*/  0x2021 0x00B7 0x201A 0x201E 0x2030 0x00C2 0x00CA 0x00C1 0x00CB 0x00C8 0x00CD 0x00CE 0x00CF 0x00CC 0x00D3 0x00D4

 /*240-255*/  0xF8FF 0x00D2 0x00DA 0x00DB 0x00D9 0x0131 0x02C6 0x02DC 0x00AF 0x02D8 0x02D9 0x02DA 0x00B8 0x02DD 0x02DB 0x02C7

ENDTABLE

ENDCONVERT

Posted by Riverside Software on 30-May-2018 06:33
Posted by goo on 30-May-2018 07:04

Aah, thanks :-) I knew someone had done that. Is it possible to implement this convertion table only for the clientside? And if so, how ? I have tried to digg into the documentation, but no luck.

Posted by riverside on 30-May-2018 09:30

The build process of the project is using proutil codepage-compiler to generate a convmap.cp.
You then have to include this convmap.cp file in the client session with -convmap startup parameter

Gilles

Posted by goo on 31-May-2018 01:28

Thanx a lot :-)

This thread is closed