Ruby: include/ruby/internal/encoding/ctype.h Source File

Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)

ctype.h
Go to the documentation of this file.
1#ifndef RUBY_INTERNAL_ENCODING_CTYPE_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_INTERNAL_ENCODING_CTYPE_H
23
24#include "ruby/onigmo.h"
25#include "ruby/internal/attr/const.h"
26#include "ruby/internal/dllexport.h"
27#include "ruby/internal/encoding/encoding.h"
28#include "ruby/internal/value.h"
29
30 RBIMPL_SYMBOL_EXPORT_BEGIN()
31
32
42static inline bool
43rb_enc_is_newline(const char *p, const char *e, rb_encoding *enc)
44{
45 OnigUChar *up = RBIMPL_CAST((OnigUChar *)p);
46 OnigUChar *ue = RBIMPL_CAST((OnigUChar *)e);
47
48 return ONIGENC_IS_MBC_NEWLINE(enc, up, ue);
49}
50
62static inline bool
63rb_enc_isctype(OnigCodePoint c, OnigCtype t, rb_encoding *enc)
64{
65 return ONIGENC_IS_CODE_CTYPE(enc, c, t);
66}
67
81static inline bool
82rb_enc_isascii(OnigCodePoint c, rb_encoding *enc)
83{
84 return ONIGENC_IS_CODE_ASCII(c);
85}
86
95static inline bool
96rb_enc_isalpha(OnigCodePoint c, rb_encoding *enc)
97{
98 return ONIGENC_IS_CODE_ALPHA(enc, c);
99}
100
109static inline bool
110rb_enc_islower(OnigCodePoint c, rb_encoding *enc)
111{
112 return ONIGENC_IS_CODE_LOWER(enc, c);
113}
114
123static inline bool
124rb_enc_isupper(OnigCodePoint c, rb_encoding *enc)
125{
126 return ONIGENC_IS_CODE_UPPER(enc, c);
127}
128
137static inline bool
138rb_enc_iscntrl(OnigCodePoint c, rb_encoding *enc)
139{
140 return ONIGENC_IS_CODE_CNTRL(enc, c);
141}
142
151static inline bool
152rb_enc_ispunct(OnigCodePoint c, rb_encoding *enc)
153{
154 return ONIGENC_IS_CODE_PUNCT(enc, c);
155}
156
165static inline bool
166rb_enc_isalnum(OnigCodePoint c, rb_encoding *enc)
167{
168 return ONIGENC_IS_CODE_ALNUM(enc, c);
169}
170
179static inline bool
180rb_enc_isprint(OnigCodePoint c, rb_encoding *enc)
181{
182 return ONIGENC_IS_CODE_PRINT(enc, c);
183}
184
193static inline bool
194rb_enc_isspace(OnigCodePoint c, rb_encoding *enc)
195{
196 return ONIGENC_IS_CODE_SPACE(enc, c);
197}
198
207static inline bool
208rb_enc_isdigit(OnigCodePoint c, rb_encoding *enc)
209{
210 return ONIGENC_IS_CODE_DIGIT(enc, c);
211}
212
213 RBIMPL_ATTR_CONST()
225int rb_enc_toupper(int c, rb_encoding *enc);
226
227 RBIMPL_ATTR_CONST()
239int rb_enc_tolower(int c, rb_encoding *enc);
240
241 RBIMPL_SYMBOL_EXPORT_END()
242
244#define rb_enc_is_newline rb_enc_is_newline
245#define rb_enc_isalnum rb_enc_isalnum
246#define rb_enc_isalpha rb_enc_isalpha
247#define rb_enc_isascii rb_enc_isascii
248#define rb_enc_isctype rb_enc_isctype
249#define rb_enc_isdigit rb_enc_isdigit
250#define rb_enc_islower rb_enc_islower
251#define rb_enc_isprint rb_enc_isprint
252#define rb_enc_iscntrl rb_enc_iscntrl
253#define rb_enc_ispunct rb_enc_ispunct
254#define rb_enc_isspace rb_enc_isspace
255#define rb_enc_isupper rb_enc_isupper
257
258#endif /* RUBY_INTERNAL_ENCODING_CTYPE_H */
const.h
Defines RBIMPL_ATTR_CONST.
RBIMPL_ATTR_CONST
#define RBIMPL_ATTR_CONST()
Wraps (or simulates) __attribute__((const)).
Definition const.h:36
dllexport.h
Tweaking visibility of C variables/functions.
RBIMPL_SYMBOL_EXPORT_END
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
RBIMPL_SYMBOL_EXPORT_BEGIN
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
rb_enc_ispunct
static bool rb_enc_ispunct(OnigCodePoint c, rb_encoding *enc)
Identical to rb_ispunct(), except it additionally takes an encoding.
Definition ctype.h:152
rb_enc_isalpha
static bool rb_enc_isalpha(OnigCodePoint c, rb_encoding *enc)
Identical to rb_isalpha(), except it additionally takes an encoding.
Definition ctype.h:96
rb_enc_isupper
static bool rb_enc_isupper(OnigCodePoint c, rb_encoding *enc)
Identical to rb_isupper(), except it additionally takes an encoding.
Definition ctype.h:124
rb_enc_isascii
static bool rb_enc_isascii(OnigCodePoint c, rb_encoding *enc)
Identical to rb_isascii(), except it additionally takes an encoding.
Definition ctype.h:82
rb_enc_is_newline
static bool rb_enc_is_newline(const char *p, const char *e, rb_encoding *enc)
Queries if the passed pointer points to a newline character.
Definition ctype.h:43
rb_enc_iscntrl
static bool rb_enc_iscntrl(OnigCodePoint c, rb_encoding *enc)
Identical to rb_iscntrl(), except it additionally takes an encoding.
Definition ctype.h:138
rb_enc_isprint
static bool rb_enc_isprint(OnigCodePoint c, rb_encoding *enc)
Identical to rb_isprint(), except it additionally takes an encoding.
Definition ctype.h:180
rb_enc_isctype
static bool rb_enc_isctype(OnigCodePoint c, OnigCtype t, rb_encoding *enc)
Queries if the passed code point is of passed character type in the passed encoding.
Definition ctype.h:63
rb_enc_islower
static bool rb_enc_islower(OnigCodePoint c, rb_encoding *enc)
Identical to rb_islower(), except it additionally takes an encoding.
Definition ctype.h:110
rb_enc_isspace
static bool rb_enc_isspace(OnigCodePoint c, rb_encoding *enc)
Identical to rb_isspace(), except it additionally takes an encoding.
Definition ctype.h:194
rb_enc_isalnum
static bool rb_enc_isalnum(OnigCodePoint c, rb_encoding *enc)
Identical to rb_isalnum(), except it additionally takes an encoding.
Definition ctype.h:166
rb_enc_isdigit
static bool rb_enc_isdigit(OnigCodePoint c, rb_encoding *enc)
Identical to rb_isdigit(), except it additionally takes an encoding.
Definition ctype.h:208
encoding.h
Defines rb_encoding.
inline
#define inline
Old Visual Studio versions do not support the inline keyword, so we need to define it to be __inline.
Definition defines.h:91
value.h
Defines VALUE and ID.