Skip to content

Commit f654058

Browse files
committed
Add macThai
1 parent f0f057b commit f654058

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

bin/encodings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ when "koi8-r" then table(Encoding::KOI8_R)
8383
when "macgreek" then table(Encoding::MACGREEK)
8484
when "maciceland" then table(Encoding::MACICELAND)
8585
when "macromania" then table(Encoding::MACROMANIA)
86+
when "macthai" then table(Encoding::MACTHAI)
8687
when "macturkish" then table(Encoding::MACTURKISH)
8788
when "shift_jis" then lists("shift_jis", 0...0x10000, Encoding::Shift_JIS)
8889
when "utf8" then table(Encoding::UTF_8) and lists("utf8", 0x100...0x110000, Encoding::UTF_8)

docs/encoding.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The key of the comment can be either "encoding" or "coding". The value of the co
4949
* `macGreek`
5050
* `macIceland`
5151
* `macRomania`
52+
* `macThai`
5253
* `macTurkish`
5354
* `Shift_JIS`
5455
* `US-ASCII`

include/prism/enc/pm_encoding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ extern pm_encoding_t pm_encoding_koi8_r;
193193
extern pm_encoding_t pm_encoding_mac_greek;
194194
extern pm_encoding_t pm_encoding_mac_iceland;
195195
extern pm_encoding_t pm_encoding_mac_romania;
196+
extern pm_encoding_t pm_encoding_mac_thai;
196197
extern pm_encoding_t pm_encoding_mac_turkish;
197198
extern pm_encoding_t pm_encoding_shift_jis;
198199
extern pm_encoding_t pm_encoding_utf_8;

src/enc/pm_tables.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,30 @@ static uint8_t pm_encoding_mac_romania_table[256] = {
792792
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
793793
};
794794

795+
/**
796+
* Each element of the following table contains a bitfield that indicates a
797+
* piece of information about the corresponding macThai character.
798+
*/
799+
static uint8_t pm_encoding_mac_thai_table[256] = {
800+
// 0 1 2 3 4 5 6 7 8 9 A B C D E F
801+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x
802+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 1x
803+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 2x
804+
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, // 3x
805+
0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // 4x
806+
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, // 5x
807+
0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 6x
808+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, // 7x
809+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8x
810+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9x
811+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ax
812+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Bx
813+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Cx
814+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Dx
815+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Ex
816+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // Fx
817+
};
818+
795819
/**
796820
* Each element of the following table contains a bitfield that indicates a
797821
* piece of information about the corresponding macTurkish character.
@@ -1129,6 +1153,7 @@ PRISM_ENCODING_TABLE(koi8_r)
11291153
PRISM_ENCODING_TABLE(mac_greek)
11301154
PRISM_ENCODING_TABLE(mac_iceland)
11311155
PRISM_ENCODING_TABLE(mac_romania)
1156+
PRISM_ENCODING_TABLE(mac_thai)
11321157
PRISM_ENCODING_TABLE(mac_turkish)
11331158
PRISM_ENCODING_TABLE(windows_1250)
11341159
PRISM_ENCODING_TABLE(windows_1251)
@@ -1482,6 +1507,16 @@ pm_encoding_t pm_encoding_mac_romania = {
14821507
.multibyte = false
14831508
};
14841509

1510+
/** macThai */
1511+
pm_encoding_t pm_encoding_mac_thai = {
1512+
.name = "macThai",
1513+
.char_width = pm_encoding_single_char_width,
1514+
.alnum_char = pm_encoding_mac_thai_alnum_char,
1515+
.alpha_char = pm_encoding_mac_thai_alpha_char,
1516+
.isupper_char = pm_encoding_mac_thai_isupper_char,
1517+
.multibyte = false
1518+
};
1519+
14851520
/** macTurkish */
14861521
pm_encoding_t pm_encoding_mac_turkish = {
14871522
.name = "macTurkish",

src/prism.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6138,6 +6138,7 @@ parser_lex_magic_comment_encoding_value(pm_parser_t *parser, const uint8_t *star
61386138
ENCODING1("macGreek", pm_encoding_mac_greek);
61396139
ENCODING1("macIceland", pm_encoding_mac_iceland);
61406140
ENCODING1("macRomania", pm_encoding_mac_romania);
6141+
ENCODING1("macThai", pm_encoding_mac_thai);
61416142
ENCODING1("macTurkish", pm_encoding_mac_turkish);
61426143
break;
61436144
case 'P': case 'p':

test/prism/encoding_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class EncodingTest < TestCase
4141
Encoding::MACGREEK => 0x00...0x100,
4242
Encoding::MACICELAND => 0x00...0x100,
4343
Encoding::MACROMANIA => 0x00...0x100,
44+
Encoding::MACTHAI => 0x00...0x100,
4445
Encoding::MACTURKISH => 0x00...0x100,
4546
Encoding::Windows_1250 => 0x00...0x100,
4647
Encoding::Windows_1251 => 0x00...0x100,

0 commit comments

Comments
 (0)