static Scheme_Object * char_to_integer (int argc, Scheme_Object *argv[]) { mzchar c; if (!SCHEME_CHARP(argv[0])) scheme_wrong_type("char->integer", "character", 0, argc, argv); c = SCHEME_CHAR_VAL(argv[0]); return scheme_make_integer_value(c); }
Scheme_Object * scheme_checked_char_to_integer (int argc, Scheme_Object *argv[]) { mzchar c; if (!SCHEME_CHARP(argv[0])) scheme_wrong_contract("char->integer", "char?", 0, argc, argv); c = SCHEME_CHAR_VAL(argv[0]); return scheme_make_integer_value(c); }
static Scheme_Object *char_general_category (int argc, Scheme_Object *argv[]) { mzchar c; int cat; if (!SCHEME_CHARP(argv[0])) scheme_wrong_type("char-general-category", "character", 0, argc, argv); c = SCHEME_CHAR_VAL(argv[0]); cat = scheme_general_category(c); return general_category_symbols[cat]; }
static Scheme_Object *char_utf8_length (int argc, Scheme_Object *argv[]) { mzchar wc; if (!SCHEME_CHARP(argv[0])) scheme_wrong_type("char-utf-8-length", "character", 0, argc, argv); wc = SCHEME_CHAR_VAL(argv[0]); if (wc < 0x80) { return scheme_make_integer(1); } else if (wc < 0x800) { return scheme_make_integer(2); } else if (wc < 0x10000) { return scheme_make_integer(3); } else if (wc < 0x200000) { return scheme_make_integer(4); } else if (wc < 0x4000000) { return scheme_make_integer(5); } else { return scheme_make_integer(6); } }
static Scheme_Object * char_p (int argc, Scheme_Object *argv[]) { return (SCHEME_CHARP(argv[0]) ? scheme_true : scheme_false); }
static Scheme_Object * interned_char_p (int argc, Scheme_Object *argv[]) { return (SCHEME_CHARP(argv[0]) && SCHEME_CHAR_VAL(argv[0]) < 256) ? scheme_true : scheme_false; }