|
| 1 | +/* |
| 2 | + * Copyright 2018 ABSA Group Limited |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package za.co.absa.cobrix.cobol.parser.encoding.codepage |
| 18 | + |
| 19 | +/** |
| 20 | + * EBCDIC code page 1142. Denmark and Norway. |
| 21 | + * |
| 22 | + * It corresponds to code page 277 and only differs from it in position 5A, where the euro sign € is located instead |
| 23 | + * of the international currency symbol ¤. |
| 24 | + */ |
| 25 | +class CodePage1142 extends SingleByteCodePage(CodePage1142.ebcdicToAsciiMapping) { |
| 26 | + override def codePageShortName: String = "cp1142" |
| 27 | +} |
| 28 | + |
| 29 | +object CodePage1142 { |
| 30 | + val ebcdicToAsciiMapping: Array[Char] = { |
| 31 | + import EbcdicNonPrintable._ |
| 32 | + |
| 33 | + /* This is the EBCDIC Code Page 1142 to ASCII conversion table |
| 34 | + from https://en.wikibooks.org/wiki/Character_Encodings/Code_Tables/EBCDIC/EBCDIC_277 */ |
| 35 | + val ebcdic2ascii: Array[Char] = { |
| 36 | + // Non-printable characters map used: http://www.pacsys.com/asciitab.htm |
| 37 | + Array[Char]( |
| 38 | + c00, c01, c02, c03, spc, c09, spc, del, spc, spc, spc, c0b, c0c, ccr, c0e, c0f, // 0 - 15 |
| 39 | + c10, c11, c12, c13, spc, nel, c08, spc, c18, c19, spc, spc, c1c, c1d, c1e, c1f, // 16 - 31 |
| 40 | + spc, spc, spc, spc, spc, clf, c17, c1b, spc, spc, spc, spc, spc, c05, c06, c07, // 32 - 47 |
| 41 | + spc, spc, c16, spc, spc, spc, spc, c04, spc, spc, spc, spc, c14, c15, spc, c1a, // 48 - 63 |
| 42 | + ' ', rsp, 'â', 'ä', 'à', 'á', 'ã', '}', 'ç', 'ñ', '#', '.', '<', '(', '+', '!', // 64 - 79 |
| 43 | + '&', 'é', 'ê', 'ë', 'è', 'í', 'î', 'ï', 'ì', 'ß', '€', 'Å', '*', ')', ';', '^', // 80 - 95 |
| 44 | + '-', '/', 'Â', 'Ä', 'À', 'Á', 'Ã', '$', 'Ç', 'Ñ', 'ø', ',', '%', '_', '>', '?', // 96 - 111 |
| 45 | + '¦', 'É', 'Ê', 'Ë', 'È', 'Í', 'Î', 'Ï', 'Ì', '`', ':', 'Æ', 'Ø', qts, '=', qtd, // 112 - 127 |
| 46 | + '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', '«', '»', 'ð', 'ý', 'þ', '±', // 128 - 143 |
| 47 | + '°', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 'ª', 'º', '{', '¸', '[', ']', // 144 - 159 |
| 48 | + 'µ', 'ü', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '¡', '¿', 'Ð', 'Ý', 'Þ', '®', // 160 - 175 |
| 49 | + '¢', '£', '¥', '·', '©', '§', '¶', '¼', '½', '¾', '¬', '|', '¯', '¨', '´', '×', // 176 - 191 |
| 50 | + 'æ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', shy, 'ô', 'ö', 'ò', 'ó', 'õ', // 192 - 207 |
| 51 | + 'å', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', '¹', 'û', '~', 'ù', 'ú', 'ÿ', // 208 - 223 |
| 52 | + bsh, '÷', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '²', 'Ô', 'Ö', 'Ò', 'Ó', 'Õ', // 224 - 239 |
| 53 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '³', 'Û', 'Ü', 'Ù', 'Ú', spc) // 240 - 255 |
| 54 | + } |
| 55 | + ebcdic2ascii |
| 56 | + } |
| 57 | +} |
0 commit comments