Support UTF16 directly
This makes the API easier to use from javascript
This commit is contained in:
parent
3bec739202
commit
f2e7058ad9
11 changed files with 164 additions and 55 deletions
15
spec/runtime/helpers/encoding_helpers.h
Normal file
15
spec/runtime/helpers/encoding_helpers.h
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef HELPERS_ENCODING_HELPERS_H_
|
||||
#define HELPERS_ENCODING_HELPERS_H_
|
||||
|
||||
#include <string>
|
||||
#include "tree_sitter/runtime.h"
|
||||
|
||||
size_t string_char_count(TSInputEncoding, const std::string &);
|
||||
size_t utf8_char_count(const std::string &);
|
||||
size_t utf16_char_count(const std::string &);
|
||||
|
||||
long string_byte_for_character(TSInputEncoding, const std::string &, size_t byte_offset, size_t character);
|
||||
long utf8_byte_for_character(const std::string &, size_t byte_offset, size_t character);
|
||||
long utf16_byte_for_character(const std::string &, size_t byte_offset, size_t character);
|
||||
|
||||
#endif // HELPERS_ENCODING_HELPERS_H_
|
||||
Loading…
Add table
Add a link
Reference in a new issue