Skip to content

Commit fc1f6ea

Browse files
committed
IBM720 encoding
1 parent d60329e commit fc1f6ea

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

bin/encodings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ when "cp855" then table(Encoding::CP855)
5555
when "euc-jp" then lists("euc-jp", 0...0x10000, Encoding::EUC_JP)
5656
when "gbk" then lists("gbk", 0...0x10000, Encoding::GBK)
5757
when "ibm437" then table(Encoding::IBM437)
58+
when "ibm720" then table(Encoding::IBM720)
5859
when "iso-8859-1" then table(Encoding::ISO8859_1)
5960
when "iso-8859-2" then table(Encoding::ISO8859_2)
6061
when "iso-8859-3" then table(Encoding::ISO8859_3)

include/prism/enc/pm_encoding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ extern pm_encoding_t pm_encoding_cp855;
165165
extern pm_encoding_t pm_encoding_euc_jp;
166166
extern pm_encoding_t pm_encoding_gbk;
167167
extern pm_encoding_t pm_encoding_ibm437;
168+
extern pm_encoding_t pm_encoding_ibm720;
168169
extern pm_encoding_t pm_encoding_iso_8859_1;
169170
extern pm_encoding_t pm_encoding_iso_8859_2;
170171
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
@@ -120,6 +120,30 @@ static uint8_t pm_encoding_ibm437_table[256] = {
120120
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
121121
};
122122

123+
/**
124+
* Each element of the following table contains a bitfield that indicates a
125+
* piece of information about the corresponding IBM720 character.
126+
*/
127+
static uint8_t pm_encoding_ibm720_table[256] = {
128+
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
129+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
130+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
131+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
132+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
133+
0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
134+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
135+
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
136+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
137+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
138+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
139+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
140+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
141+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
142+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
143+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
144+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
145+
};
146+
123147
/**
124148
* Each element of the following table contains a bitfield that indicates a
125149
* piece of information about the corresponding ISO-8859-1 character.
@@ -789,6 +813,7 @@ PRISM_ENCODING_TABLE(cp850)
789813
PRISM_ENCODING_TABLE(cp852)
790814
PRISM_ENCODING_TABLE(cp855)
791815
PRISM_ENCODING_TABLE(ibm437)
816+
PRISM_ENCODING_TABLE(ibm720)
792817
PRISM_ENCODING_TABLE(iso_8859_1)
793818
PRISM_ENCODING_TABLE(iso_8859_2)
794819
PRISM_ENCODING_TABLE(iso_8859_3)
@@ -877,6 +902,16 @@ pm_encoding_t pm_encoding_ibm437 = {
877902
.multibyte = false
878903
};
879904

905+
/** IBM720 */
906+
pm_encoding_t pm_encoding_ibm720 = {
907+
.name = "IBM720",
908+
.char_width = pm_encoding_single_char_width,
909+
.alnum_char = pm_encoding_ibm720_alnum_char,
910+
.alpha_char = pm_encoding_ibm720_alpha_char,
911+
.isupper_char = pm_encoding_ibm720_isupper_char,
912+
.multibyte = false
913+
};
914+
880915
/** ISO-8859-1 */
881916
pm_encoding_t pm_encoding_iso_8859_1 = {
882917
.name = "ISO-8859-1",

src/prism.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6073,6 +6073,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
60736073
ENCODING1("CP855", pm_encoding_cp855);
60746074
ENCODING2("GBK", "CP936", pm_encoding_gbk);
60756075
ENCODING2("IBM437", "CP437", pm_encoding_ibm437);
6076+
ENCODING2("IBM720", "CP720", pm_encoding_ibm720);
60766077
ENCODING2("ISO-8859-1", "ISO8859-1", pm_encoding_iso_8859_1);
60776078
ENCODING2("ISO-8859-2", "ISO8859-2", pm_encoding_iso_8859_2);
60786079
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
@@ -15,6 +15,7 @@ class EncodingTest < TestCase
1515
Encoding::EUC_JP,
1616
Encoding::GBK,
1717
Encoding::IBM437,
18+
Encoding::IBM720,
1819
Encoding::ISO_8859_1,
1920
Encoding::ISO_8859_2,
2021
Encoding::ISO_8859_3,

0 commit comments

Comments
 (0)