Ruby 3.4.5p51 (2025-07-16 revision 20cda200d3ce092571d0b5d342dadca69636cb0f)
|
Arithmetic conversion between C's char and Ruby's. More...
#include "ruby/internal/arithmetic/int.h"
#include "ruby/internal/arithmetic/long.h"
#include "ruby/internal/attr/artificial.h"
#include "ruby/internal/attr/const.h"
#include "ruby/internal/attr/constexpr.h"
#include "ruby/internal/cast.h"
#include "ruby/internal/core/rstring.h"
#include "ruby/internal/value_type.h"
Go to the source code of this file.
Macros | |
#define | RB_NUM2CHR rb_num2char_inline |
Just another name of rb_num2char_inline. | |
#define | NUM2CHR RB_NUM2CHR |
Old name of RB_NUM2CHR. | |
#define | CHR2FIX RB_CHR2FIX |
Old name of RB_CHR2FIX. |
Functions | |
static VALUE | RB_CHR2FIX (unsigned char c) |
Converts a C's unsigned char into an instance of rb_cInteger. | |
static char | rb_num2char_inline (VALUE x) |
Converts an instance of rb_cNumeric into C's char. |
Arithmetic conversion between C's char and Ruby's.
Definition in file char.h.
#define RB_NUM2CHR rb_num2char_inline |
Just another name of rb_num2char_inline.
|
inlinestatic |
Converts a C's unsigned char into an instance of rb_cInteger.
[in] | c | Arbitrary unsigned char value. |
Definition at line 56 of file char.h.
Referenced by RB_CHR2FIX().
|
inlinestatic |
Converts an instance of rb_cNumeric into C's char.
At the same time it accepts a String of more than one character, and returns its first byte. In the early days there was a Ruby level "character" literal ?c, which roughly worked this way.
[in] | x | Either a string or a numeric. |
rb_eTypeError | `x` is not a numeric. |
rb_eRangeError | `x` is out of range of `unsigned int`. |