Add parse function that accepts input encoding

This commit is contained in:
Zach Waugh 2018-11-21 15:55:24 -05:00
parent 9ac496aced
commit 2be55244fc
2 changed files with 8 additions and 2 deletions

View file

@ -87,7 +87,7 @@ typedef enum {
} ErrorComparison;
typedef struct {
const char *string;
const void *string;
uint32_t length;
} TSStringInput;
@ -1643,11 +1643,16 @@ TSTree *ts_parser_parse(TSParser *self, const TSTree *old_tree, TSInput input) {
TSTree *ts_parser_parse_string(TSParser *self, const TSTree *old_tree,
const char *string, uint32_t length) {
return ts_parser_parse_string_encoding(self, old_tree, string, length, TSInputEncodingUTF8);
}
TSTree *ts_parser_parse_string_encoding(TSParser *self, const TSTree *old_tree,
const void *string, uint32_t length, TSInputEncoding encoding) {
TSStringInput input = {string, length};
return ts_parser_parse(self, old_tree, (TSInput) {
&input,
ts_string_input_read,
TSInputEncodingUTF8,
encoding,
});
}