Skip to content

Commit abc136d

Browse files
committed
Add IBM864 encoding
Fixes #1868 Related #1843
1 parent 5233c68 commit abc136d

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

bin/encodings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ when "ibm857" then table(Encoding::IBM857)
6464
when "ibm860" then table(Encoding::IBM860)
6565
when "ibm861" then table(Encoding::IBM861)
6666
when "ibm862" then table(Encoding::IBM862)
67+
when "ibm864" then table(Encoding::IBM864)
6768
when "iso-8859-1" then table(Encoding::ISO8859_1)
6869
when "iso-8859-2" then table(Encoding::ISO8859_2)
6970
when "iso-8859-3" then table(Encoding::ISO8859_3)

docs/encoding.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The key of the comment can be either "encoding" or "coding". The value of the co
3030
* `IBM860`
3131
* `IBM861`
3232
* `IBM862`
33+
* `IBM864`
3334
* `ISO-8859-1`
3435
* `ISO-8859-2`
3536
* `ISO-8859-3`

include/prism/enc/pm_encoding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ extern pm_encoding_t pm_encoding_ibm857;
174174
extern pm_encoding_t pm_encoding_ibm860;
175175
extern pm_encoding_t pm_encoding_ibm861;
176176
extern pm_encoding_t pm_encoding_ibm862;
177+
extern pm_encoding_t pm_encoding_ibm864;
177178
extern pm_encoding_t pm_encoding_iso_8859_1;
178179
extern pm_encoding_t pm_encoding_iso_8859_2;
179180
extern pm_encoding_t pm_encoding_iso_8859_3;

src/enc/pm_tables.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,30 @@ static uint8_t pm_encoding_ibm862_table[256] = {
336336
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
337337
};
338338

339+
/**
340+
* Each element of the following table contains a bitfield that indicates a
341+
* piece of information about the corresponding IBM864 character.
342+
*/
343+
static uint8_t pm_encoding_ibm864_table[256] = {
344+
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
345+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
346+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
347+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
348+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
349+
0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
350+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
351+
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
352+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
353+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
354+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
355+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
356+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
357+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
358+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
359+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
360+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
361+
};
362+
339363
/**
340364
* Each element of the following table contains a bitfield that indicates a
341365
* piece of information about the corresponding ISO-8859-1 character.
@@ -1206,6 +1230,7 @@ PRISM_ENCODING_TABLE(ibm857)
12061230
PRISM_ENCODING_TABLE(ibm860)
12071231
PRISM_ENCODING_TABLE(ibm861)
12081232
PRISM_ENCODING_TABLE(ibm862)
1233+
PRISM_ENCODING_TABLE(ibm864)
12091234
PRISM_ENCODING_TABLE(iso_8859_1)
12101235
PRISM_ENCODING_TABLE(iso_8859_2)
12111236
PRISM_ENCODING_TABLE(iso_8859_3)
@@ -1392,6 +1417,16 @@ pm_encoding_t pm_encoding_ibm862 = {
13921417
.multibyte = false
13931418
};
13941419

1420+
/** IBM864 */
1421+
pm_encoding_t pm_encoding_ibm864 = {
1422+
.name = "IBM864",
1423+
.char_width = pm_encoding_single_char_width,
1424+
.alnum_char = pm_encoding_ibm864_alnum_char,
1425+
.alpha_char = pm_encoding_ibm864_alpha_char,
1426+
.isupper_char = pm_encoding_ibm864_isupper_char,
1427+
.multibyte = false
1428+
};
1429+
13951430
/** ISO-8859-1 */
13961431
pm_encoding_t pm_encoding_iso_8859_1 = {
13971432
.name = "ISO-8859-1",

src/prism.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6075,6 +6075,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
60756075
ENCODING1("CP860", pm_encoding_ibm860);
60766076
ENCODING1("CP861", pm_encoding_ibm861);
60776077
ENCODING1("CP862", pm_encoding_ibm862);
6078+
ENCODING1("CP864", pm_encoding_ibm864);
60786079
ENCODING1("CP874", pm_encoding_windows_874);
60796080
ENCODING1("CP878", pm_encoding_koi8_r);
60806081
ENCODING2("CP932", "csWindows31J", pm_encoding_windows_31j);
@@ -6113,6 +6114,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
61136114
ENCODING1("IBM860", pm_encoding_ibm860);
61146115
ENCODING1("IBM861", pm_encoding_ibm861);
61156116
ENCODING1("IBM862", pm_encoding_ibm862);
6117+
ENCODING1("IBM864", pm_encoding_ibm864);
61166118
ENCODING2("ISO-8859-1", "ISO8859-1", pm_encoding_iso_8859_1);
61176119
ENCODING2("ISO-8859-2", "ISO8859-2", pm_encoding_iso_8859_2);
61186120
ENCODING2("ISO-8859-3", "ISO8859-3", pm_encoding_iso_8859_3);

test/prism/encoding_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class EncodingTest < TestCase
2222
Encoding::IBM860 => 0x00...0x100,
2323
Encoding::IBM861 => 0x00...0x100,
2424
Encoding::IBM862 => 0x00...0x100,
25+
Encoding::IBM864 => 0x00...0x100,
2526
Encoding::ISO_8859_1 => 0x00...0x100,
2627
Encoding::ISO_8859_2 => 0x00...0x100,
2728
Encoding::ISO_8859_3 => 0x00...0x100,

0 commit comments

Comments
 (0)