Prism Ruby parser
Loading...
Searching...
No Matches
Data Fields
pm_encoding_t Struct Reference

This struct defines the functions necessary to implement the encoding interface so we can determine how many bytes the subsequent character takes. More...

#include <encoding.h>

Data Fields

size_t(* char_width )(const uint8_t *b, ptrdiff_t n)
 Return the number of bytes that the next character takes if it is valid in the encoding.
 
size_t(* alpha_char )(const uint8_t *b, ptrdiff_t n)
 Return the number of bytes that the next character takes if it is valid in the encoding and is alphabetical.
 
size_t(* alnum_char )(const uint8_t *b, ptrdiff_t n)
 Return the number of bytes that the next character takes if it is valid in the encoding and is alphanumeric.
 
bool(* isupper_char )(const uint8_t *b, ptrdiff_t n)
 Return true if the next character is valid in the encoding and is an uppercase character.
 
const char * name
 The name of the encoding.
 
bool multibyte
 Return true if the encoding is a multibyte encoding.
 

Detailed Description

This struct defines the functions necessary to implement the encoding interface so we can determine how many bytes the subsequent character takes.

Each callback should return the number of bytes, or 0 if the next bytes are invalid for the encoding and type.

Field Documentation

◆ char_width

size_t(* pm_encoding_t::char_width) (const uint8_t *b, ptrdiff_t n)

Return the number of bytes that the next character takes if it is valid in the encoding.

Does not read more than n bytes. It is assumed that n is at least 1.

◆ alpha_char

size_t(* pm_encoding_t::alpha_char) (const uint8_t *b, ptrdiff_t n)

Return the number of bytes that the next character takes if it is valid in the encoding and is alphabetical.

Does not read more than n bytes. It is assumed that n is at least 1.

◆ alnum_char

size_t(* pm_encoding_t::alnum_char) (const uint8_t *b, ptrdiff_t n)

Return the number of bytes that the next character takes if it is valid in the encoding and is alphanumeric.

Does not read more than n bytes. It is assumed that n is at least 1.

◆ isupper_char

bool(* pm_encoding_t::isupper_char) (const uint8_t *b, ptrdiff_t n)

Return true if the next character is valid in the encoding and is an uppercase character.

Does not read more than n bytes. It is assumed that n is at least 1.

◆ name

const char* pm_encoding_t::name

The name of the encoding.

This should correspond to a value that can be passed to Encoding.find in Ruby.


The documentation for this struct was generated from the following file: