|
| 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 1160 with support for Thai script used in IBM mainframes which is same as 838 |
| 21 | + * with € at the position 0xFE. |
| 22 | + */ |
| 23 | +class CodePage1160 extends SingleByteCodePage(CodePage1160.ebcdicToAsciiMapping) { |
| 24 | + override def codePageShortName: String = "cp1160" |
| 25 | +} |
| 26 | + |
| 27 | +object CodePage1160 { |
| 28 | + val ebcdicToAsciiMapping: Array[Char] = { |
| 29 | + import EbcdicNonPrintable._ |
| 30 | + |
| 31 | + /* This is the EBCDIC Code Page 1160 to ASCII conversion table |
| 32 | + from https://en.wikibooks.org/wiki/Character_Encodings/Code_Tables/EBCDIC/EBCDIC_838 */ |
| 33 | + val ebcdic2ascii: Array[Char] = { |
| 34 | + val c01 = '\u0E48' |
| 35 | + val c02 = '\u0E4E' |
| 36 | + val c03 = '\u0E31' |
| 37 | + val c04 = '\u0E34' |
| 38 | + val c05 = '\u0E49' |
| 39 | + val c06 = '\u0E35' |
| 40 | + val c07 = '\u0E36' |
| 41 | + val c08 = '\u0E37' |
| 42 | + val c09 = '\u0E38' |
| 43 | + val c10 = '\u0E39' |
| 44 | + val c11 = '\u0E3A' |
| 45 | + val c12 = '\u0E47' |
| 46 | + val c13 = '\u0E48' |
| 47 | + val c14 = '\u0E49' |
| 48 | + val c15 = '\u0E4A' |
| 49 | + val c16 = '\u0E4B' |
| 50 | + val c18 = '\u0E4D' |
| 51 | + |
| 52 | + Array[Char]( |
| 53 | + spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, ccr, spc, spc, // 0 - 15 |
| 54 | + spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, // 16 - 31 |
| 55 | + spc, spc, spc, spc, spc, clf, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, // 32 - 47 |
| 56 | + spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, spc, // 48 - 63 |
| 57 | + spc, spc, 'ก', 'ข', 'ฃ', 'ค', 'ฅ', 'ฆ', 'ง', '[', '¢', '.', '<', '(', '+', '|', // 64 - 79 |
| 58 | + '&', c01, 'จ', 'ฉ', 'ช', 'ซ', 'ฌ', 'ญ', 'ฎ', ']', '!', '$', '*', ')', ';', '¬', // 80 - 95 |
| 59 | + '-', '/', 'ฏ', 'ฐ', 'ฑ', 'ฒ', 'ณ', 'ด', 'ต', '^', '¦', ',', '%', '_', '>', '?', // 96 - 111 |
| 60 | + '฿', c02, 'ถ', 'ท', 'ธ', 'น', 'บ', 'ป', 'ผ', '`', ':', '#', '@', qts, '=', qtd, // 112 - 127 |
| 61 | + '๏', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'ฝ', 'พ', 'ฟ', 'ภ', 'ม', 'ย', // 128 - 143 |
| 62 | + '๚', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 'ร', 'ฤ', 'ล', 'ฦ', 'ว', 'ศ', // 144 - 159 |
| 63 | + '๛', '~', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'ษ', 'ส', 'ห', 'ฬ', 'อ', 'ฮ', // 160 - 175 |
| 64 | + '๐', '๑', '๒', '๓', '๔', '๕', '๖', '๗', '๘', '๙', 'ฯ', 'ะ', c03, 'า', 'ำ', c04, // 176 - 191 |
| 65 | + '{', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', c05, c06, c07, c08, c09, c10, // 192 - 207 |
| 66 | + '}', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', c11, 'เ', 'แ', 'โ', 'ใ', 'ไ', // 208 - 223 |
| 67 | + bsh, c15, 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'ๅ', 'ๆ', c12, c13, c14, c15, // 224 - 239 |
| 68 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', c16, c17, c18, c16, '€', spc) // 240 - 255 |
| 69 | + } |
| 70 | + ebcdic2ascii |
| 71 | + } |
| 72 | +} |
0 commit comments