Ruby  3.4.0dev (2024-12-06 revision 892c46283a5ea4179500d951c9d4866c0051f27b)
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const char * name
 The name of the encoding. More...
 
bool multibyte
 Return true if the encoding is a multibyte encoding. More...
 

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.

Definition at line 23 of file encoding.h.

Field Documentation

◆ 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.

Definition at line 43 of file encoding.h.

◆ 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.

Definition at line 36 of file encoding.h.

◆ 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.

Definition at line 29 of file encoding.h.

Referenced by pm_memchr().

◆ 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.

Definition at line 50 of file encoding.h.

◆ multibyte

bool pm_encoding_t::multibyte

Return true if the encoding is a multibyte encoding.

Definition at line 61 of file encoding.h.

Referenced by pm_memchr(), and pm_strpbrk().

◆ 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.

Definition at line 56 of file encoding.h.

Referenced by pm_serialize_encoding().


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