Ruby 3.5.0dev (2025-02-22 revision 412997300569c1853c09813e4924b6df3d7e8669)
string.h
Go to the documentation of this file.
1#ifndef RUBY_INTERNAL_ENCODING_STRING_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RUBY_INTERNAL_ENCODING_STRING_H
25#include "ruby/internal/value.h"
28#include "ruby/internal/intern/string.h" /* rbimpl_strlen */
29
31
32
48VALUE rb_enc_str_new(const char *ptr, long len, rb_encoding *enc);
49
67VALUE rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc);
68
87VALUE rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc);
88
106VALUE rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc);
107
122VALUE rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc);
123
136long rb_enc_strlen(const char *head, const char *tail, rb_encoding *enc);
137
152char *rb_enc_nth(const char *head, const char *tail, long nth, rb_encoding *enc);
153
162
176VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
177
196VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc);
197
224VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *enc);
225
235
247
264VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
265
276
292long rb_str_coderange_scan_restartable(const char *str, const char *end, rb_encoding *enc, int *cr);
293
305
319long rb_memsearch(const void *x, long m, const void *y, long n, rb_encoding *enc);
320
323static inline VALUE
324rbimpl_enc_str_new_cstr(const char *str, rb_encoding *enc)
325{
326 long len = rbimpl_strlen(str);
327
328 return rb_enc_str_new_static(str, len, enc);
329}
330
331#define rb_enc_str_new(str, len, enc) \
332 ((RBIMPL_CONSTANT_P(str) && \
333 RBIMPL_CONSTANT_P(len) ? \
334 rb_enc_str_new_static: \
335 rb_enc_str_new) ((str), (len), (enc)))
336
337#define rb_enc_str_new_cstr(str, enc) \
338 ((RBIMPL_CONSTANT_P(str) ? \
339 rbimpl_enc_str_new_cstr : \
340 rb_enc_str_new_cstr) ((str), (enc)))
341
345
346#endif /* RUBY_INTERNAL_ENCODING_STRING_H */
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
Defines rb_encoding.
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
Encoding conversion main routine.
Definition string.c:1286
int rb_enc_str_coderange(VALUE str)
Scans the passed string to collect its code range.
Definition string.c:901
VALUE rb_enc_uint_chr(unsigned int code, rb_encoding *enc)
Encodes the passed code point into a series of bytes.
Definition numeric.c:3803
VALUE rb_enc_str_new_static(const char *ptr, long len, rb_encoding *enc)
Identical to rb_enc_str_new(), except it takes a C string literal.
Definition string.c:1151
char * rb_enc_nth(const char *head, const char *tail, long nth, rb_encoding *enc)
Queries the n-th character.
Definition string.c:2927
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
Identical to rb_str_conv_enc(), except it additionally takes IO encoder options.
Definition string.c:1170
VALUE rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc)
Identical to rb_enc_str_new(), except it returns a "f"string.
Definition string.c:12535
long rb_memsearch(const void *x, long m, const void *y, long n, rb_encoding *enc)
Looks for the passed string in the passed buffer.
Definition re.c:252
long rb_enc_strlen(const char *head, const char *tail, rb_encoding *enc)
Counts the number of characters of the passed string, according to the passed encoding.
Definition string.c:2250
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc)
Identical to rb_str_cat(), except it additionally takes an encoding.
Definition string.c:3612
VALUE rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc)
Identical to rb_enc_str_new(), except it assumes the passed pointer is a pointer to a C string.
Definition string.c:1099
VALUE rb_str_export_to_enc(VALUE obj, rb_encoding *enc)
Identical to rb_str_export(), except it additionally takes an encoding.
Definition string.c:1391
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *enc)
Identical to rb_external_str_new(), except it additionally takes an encoding.
Definition string.c:1292
int rb_enc_str_asciionly_p(VALUE str)
Queries if the passed string is "ASCII only".
Definition string.c:920
VALUE rb_obj_encoding(VALUE obj)
Identical to rb_enc_get_index(), except the return type.
Definition encoding.c:1163
VALUE rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc)
Identical to rb_enc_str_new_cstr(), except it returns a "f"string.
Definition string.c:12557
long rb_str_coderange_scan_restartable(const char *str, const char *end, rb_encoding *enc, int *cr)
Scans the passed string until it finds something odd.
Definition string.c:785
Public APIs related to rb_cString.
int len
Length of the buffer.
Definition io.h:8
Defines RBIMPL_ATTR_NONNULL.
#define RBIMPL_ATTR_NONNULL(list)
Wraps (or simulates) __attribute__((nonnull))
Definition nonnull.h:30
#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
Defines VALUE and ID.
uintptr_t VALUE
Type that represents a Ruby object.
Definition value.h:40