Skip to content

Commit 45251fc

Browse files
committed
IBM852 encoding
1 parent 80fac1e commit 45251fc

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
@@ -58,6 +58,7 @@ when "ibm437" then table(Encoding::IBM437)
5858
when "ibm720" then table(Encoding::IBM720)
5959
when "ibm737" then table(Encoding::IBM737)
6060
when "ibm775" then table(Encoding::IBM775)
61+
when "ibm852" then table(Encoding::IBM852)
6162
when "iso-8859-1" then table(Encoding::ISO8859_1)
6263
when "iso-8859-2" then table(Encoding::ISO8859_2)
6364
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
@@ -168,6 +168,7 @@ extern pm_encoding_t pm_encoding_ibm437;
168168
extern pm_encoding_t pm_encoding_ibm720;
169169
extern pm_encoding_t pm_encoding_ibm737;
170170
extern pm_encoding_t pm_encoding_ibm775;
171+
extern pm_encoding_t pm_encoding_ibm852;
171172
extern pm_encoding_t pm_encoding_iso_8859_1;
172173
extern pm_encoding_t pm_encoding_iso_8859_2;
173174
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
@@ -192,6 +192,30 @@ static uint8_t pm_encoding_ibm775_table[256] = {
192192
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
193193
};
194194

195+
/**
196+
* Each element of the following table contains a bitfield that indicates a
197+
* piece of information about the corresponding IBM852 character.
198+
*/
199+
static uint8_t pm_encoding_ibm852_table[256] = {
200+
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
201+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
202+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
203+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
204+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
205+
0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
206+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
207+
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
208+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
209+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
210+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
211+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
212+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
213+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
214+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
215+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
216+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
217+
};
218+
195219
/**
196220
* Each element of the following table contains a bitfield that indicates a
197221
* piece of information about the corresponding ISO-8859-1 character.
@@ -864,6 +888,7 @@ PRISM_ENCODING_TABLE(ibm437)
864888
PRISM_ENCODING_TABLE(ibm720)
865889
PRISM_ENCODING_TABLE(ibm737)
866890
PRISM_ENCODING_TABLE(ibm775)
891+
PRISM_ENCODING_TABLE(ibm852)
867892
PRISM_ENCODING_TABLE(iso_8859_1)
868893
PRISM_ENCODING_TABLE(iso_8859_2)
869894
PRISM_ENCODING_TABLE(iso_8859_3)
@@ -982,6 +1007,16 @@ pm_encoding_t pm_encoding_ibm775 = {
9821007
.multibyte = false
9831008
};
9841009

1010+
/** IBM850 */
1011+
pm_encoding_t pm_encoding_ibm852 = {
1012+
.name = "IBM852",
1013+
.char_width = pm_encoding_single_char_width,
1014+
.alnum_char = pm_encoding_ibm852_alnum_char,
1015+
.alpha_char = pm_encoding_ibm852_alpha_char,
1016+
.isupper_char = pm_encoding_ibm852_isupper_char,
1017+
.multibyte = false
1018+
};
1019+
9851020
/** ISO-8859-1 */
9861021
pm_encoding_t pm_encoding_iso_8859_1 = {
9871022
.name = "ISO-8859-1",

src/prism.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6102,6 +6102,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
61026102
ENCODING1("IBM737", pm_encoding_ibm737);
61036103
ENCODING1("IBM775", pm_encoding_ibm775);
61046104
ENCODING1("IBM850", pm_encoding_cp850);
6105+
ENCODING1("IBM852", pm_encoding_ibm852);
61056106
ENCODING2("ISO-8859-1", "ISO8859-1", pm_encoding_iso_8859_1);
61066107
ENCODING2("ISO-8859-2", "ISO8859-2", pm_encoding_iso_8859_2);
61076108
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
@@ -18,6 +18,7 @@ class EncodingTest < TestCase
1818
Encoding::IBM720,
1919
Encoding::IBM737,
2020
Encoding::IBM775,
21+
Encoding::IBM852,
2122
Encoding::ISO_8859_1,
2223
Encoding::ISO_8859_2,
2324
Encoding::ISO_8859_3,

0 commit comments

Comments
 (0)