character.h File Reference

## Macros

#define | MAX_UTF8_CHAR_BYTES 6
#define | MAX_UNICODE_CHAR_BYTES 4
#define | USHORT_SIZE (sizeof (unsigned short))
#define | UINT_SIZE (sizeof (unsigned int))
#define | UNIT_BYTES(format)
#define | CHAR_UNITS_ASCII(c) ((c) < 0x80)
#define | CHAR_UNITS_UTF8(c)
#define | CHAR_UNITS_UTF16(c) ((c) < 0x110000 ? (2 - ((c) < 0x10000)) : 0)
#define | CHAR_UNITS_UTF32(c) 1
#define | CHAR_UNITS(c, format)
#define | CHAR_BYTES CHAR_UNITS_UTF8
#define | CHAR_UNITS_AT_UTF8(p)
#define | CHAR_UNITS_AT_UTF16(p)
#define | CHAR_UNITS_AT(mt, p)
#define | CHAR_BYTES_AT CHAR_UNITS_AT_UTF8
#define | CHAR_UNITS_BY_HEAD_UTF8(c)
#define | CHAR_UNITS_BY_HEAD_UTF16(c) (2 - ((unsigned short) (c) < 0xD800 || (unsigned short) (c) >= 0xDC00))
#define | CHAR_UNITS_BY_HEAD(c, format)
#define | CHAR_BYTES_BY_HEAD CHAR_UNITS_BY_HEAD_UTF8
#define | STRING_CHAR_UTF8(p)
#define | STRING_CHAR_UTF16(p)
#define | STRING_CHAR STRING_CHAR_UTF8
#define | STRING_CHAR_ADVANCE_UTF8(p)
#define | STRING_CHAR_ADVANCE_UTF16(p)
#define | STRING_CHAR_ADVANCE STRING_CHAR_ADVANCE_UTF8
#define | STRING_CHAR_AND_UNITS_UTF8(p, bytes)
#define | STRING_CHAR_AND_UNITS_UTF16(p, units)
#define | STRING_CHAR_AND_UNITS(p, units, format)
#define | STRING_CHAR_AND_BYTES STRING_CHAR_AND_UNITS_UTF8
#define | CHAR_STRING_UTF8(c, p)
#define | CHAR_STRING_UTF16(c, p)
#define | CHAR_STRING CHAR_STRING_UTF8
#define | CHAR_HEAD_P_UTF8(p) ((*(p) & 0xC0) != 0x80)
#define | CHAR_HEAD_P_UTF16(p)
#define | CHAR_HEAD_P CHAR_HEAD_P_UTF8
#define | TOLOWER(c) (((c) >= 'A' && (c) <= 'Z') ? (c) + 32 : (c))
#define | TOUPPER(c) (((c) >= 'a' && (c) <= 'z') ? (c) - 32 : (c))
#define | ISUPPER(c) ((c) >= 'A' && (c) <= 'Z')
#define | ISALNUM(c)

## Functions

void | mchar__define_prop (MSymbol key, MSymbol type, void *mdb)

## Macro Definition Documentation

## MAX_UTF8_CHAR_BYTES

#define MAX_UTF8_CHAR_BYTES 6

## MAX_UNICODE_CHAR_BYTES

#define MAX_UNICODE_CHAR_BYTES 4

## USHORT_SIZE

#define USHORT_SIZE (sizeof (unsigned short))

## UINT_SIZE

#define UINT_SIZE (sizeof (unsigned int))

## UNIT_BYTES

#define UNIT_BYTES | ( |  | format | ) |

Value:
((format) <= MTEXT_FORMAT_UTF_8 ? 1 \
: (format) <= MTEXT_FORMAT_UTF_16BE ? USHORT_SIZE \
: UINT_SIZE)
USHORT_SIZE
#define USHORT_SIZE
Definition: character.h:5
UINT_SIZE
#define UINT_SIZE
Definition: character.h:6
MTEXT_FORMAT_UTF_8
@ MTEXT_FORMAT_UTF_8
Definition: m17n-core.h:244
MTEXT_FORMAT_UTF_16BE
@ MTEXT_FORMAT_UTF_16BE
Definition: m17n-core.h:252

## CHAR_UNITS_ASCII

#define CHAR_UNITS_ASCII | ( |  | c | ) | ((c) < 0x80)

## CHAR_UNITS_UTF8

#define CHAR_UNITS_UTF8 | ( |  | c | ) |

Value:
((c) < 0x80 ? 1 \
: (c) < 0x800 ? 2 \
: (c) < 0x10000 ? 3 \
: (c) < 0x200000 ? 4 \
: (c) < 0x4000000 ? 5 \
: 6)

## CHAR_UNITS_UTF16

#define CHAR_UNITS_UTF16 | ( |  | c | ) | ((c) < 0x110000 ? (2 - ((c) < 0x10000)) : 0)

## CHAR_UNITS_UTF32

#define CHAR_UNITS_UTF32 | ( |  | c | ) | 1

## CHAR_UNITS

#define CHAR_UNITS | ( |  | c,
|  |  | format
| ) |  |

Value:
((format) <= MTEXT_FORMAT_UTF_8 ? CHAR_UNITS_UTF8 (c) \
: (format) <= MTEXT_FORMAT_UTF_16BE ? CHAR_UNITS_UTF16 (c) \
: CHAR_UNITS_UTF32 (c))
CHAR_UNITS_UTF8
#define CHAR_UNITS_UTF8(c)
Definition: character.h:12
CHAR_UNITS_UTF16
#define CHAR_UNITS_UTF16(c)
Definition: character.h:19
CHAR_UNITS_UTF32
#define CHAR_UNITS_UTF32(c)
Definition: character.h:20

## CHAR_BYTES

#define CHAR_BYTES CHAR_UNITS_UTF8

## CHAR_UNITS_AT_UTF8

#define CHAR_UNITS_AT_UTF8 | ( |  | p | ) |

Value:
(!(*(p) & 0x80) ? 1 \
: !(*(p) & 0x20) ? 2 \
: !(*(p) & 0x10) ? 3 \
: !(*(p) & 0x08) ? 4 \
: !(*(p) & 0x04) ? 5 \
: !(*(p) & 0x02) ? 6 \
: 0)

## CHAR_UNITS_AT_UTF16

#define CHAR_UNITS_AT_UTF16 | ( |  | p | ) |

Value:
(2 - (*(unsigned short *) (p) < 0xD800 \
|| *(unsigned short *) (p) >= 0xDC00))

## CHAR_UNITS_AT

#define CHAR_UNITS_AT | ( |  | mt,
|  |  | p
| ) |  |

Value:
((mt)->format <= MTEXT_FORMAT_UTF_8 ? CHAR_UNITS_AT_UTF8 (p) \
: (mt)->format <= MTEXT_FORMAT_UTF_16BE ? CHAR_UNITS_AT_UTF16 (p) \
: 1)
CHAR_UNITS_AT_UTF16
#define CHAR_UNITS_AT_UTF16(p)
Definition: character.h:34
CHAR_UNITS_AT_UTF8
#define CHAR_UNITS_AT_UTF8(p)
Definition: character.h:26

## CHAR_BYTES_AT

#define CHAR_BYTES_AT CHAR_UNITS_AT_UTF8

## CHAR_UNITS_BY_HEAD_UTF8

#define CHAR_UNITS_BY_HEAD_UTF8 | ( |  | c | ) |

Value:
(!((c) & 0x80) ? 1 \
: !((c) & 0x20) ? 2 \
: !((c) & 0x10) ? 3 \
: !((c) & 0x08) ? 4 \
: !((c) & 0x04) ? 5 \
: !((c) & 0x02) ? 6 \
: 0)

## CHAR_UNITS_BY_HEAD_UTF16

#define CHAR_UNITS_BY_HEAD_UTF16 | ( |  | c | ) | (2 - ((unsigned short) (c) < 0xD800 || (unsigned short) (c) >= 0xDC00))

## CHAR_UNITS_BY_HEAD

#define CHAR_UNITS_BY_HEAD | ( |  | c,
|  |  | format
| ) |  |

Value:
((format) <= MTEXT_FORMAT_UTF_8 ? CHAR_UNITS_BY_HEAD_UTF8 (c) \
: (format) <= MTEXT_FORMAT_UTF_16BE ? CHAR_UNITS_BY_HEAD_UTF16 (c) \
: 1)
CHAR_UNITS_BY_HEAD_UTF8
#define CHAR_UNITS_BY_HEAD_UTF8(c)
Definition: character.h:42
CHAR_UNITS_BY_HEAD_UTF16
#define CHAR_UNITS_BY_HEAD_UTF16(c)
Definition: character.h:50

## CHAR_BYTES_BY_HEAD

#define CHAR_BYTES_BY_HEAD CHAR_UNITS_BY_HEAD_UTF8

## STRING_CHAR_UTF8

#define STRING_CHAR_UTF8 | ( |  | p | ) |

Value:
(!((p)[0] & 0x80) ? (p)[0] \
: !((p)[0] & 0x20) ? ((((p)[0] & 0x1F) << 6) \
| ((p)[1] & 0x3F)) \
: !((p)[0] & 0x10) ? ((((p)[0] & 0x0F) << 12) \
| (((p)[1] & 0x3F) << 6) \
| ((p)[2] & 0x3F)) \
: !((p)[0] & 0x08) ? ((((p)[0] & 0x07) << 18) \
| (((p)[1] & 0x3F) << 12) \
| (((p)[2] & 0x3F) << 6) \
| ((p)[3] & 0x3F)) \
: !((p)[0] & 0x04) ? ((((p)[0] & 0x03) << 24) \
| (((p)[1] & 0x3F) << 18) \
| (((p)[2] & 0x3F) << 12) \
| (((p)[3] & 0x3F) << 6) \
| ((p)[4] & 0x3F)) \
: ((((p)[0] & 0x01) << 30) \
| (((p)[1] & 0x3F) << 24) \
| (((p)[2] & 0x3F) << 18) \
| (((p)[3] & 0x3F) << 12) \
| (((p)[4] & 0x3F) << 6) \
| ((p)[5] & 0x3F)))

## STRING_CHAR_UTF16

#define STRING_CHAR_UTF16 | ( |  | p | ) |

Value:
(((unsigned short) (p)[0] < 0xD800 || (unsigned short) (p)[0] >= 0xDC00) \
? (p)[0] \
: ((((p)[0] - 0xD800) << 10) + ((p)[1] - 0xDC00) + 0x10000))

## STRING_CHAR

#define STRING_CHAR STRING_CHAR_UTF8

## STRING_CHAR_ADVANCE_UTF8

#define STRING_CHAR_ADVANCE_UTF8 | ( |  | p | ) |

Value:
(!(*(p) & 0x80) ? ((p)++, (p)[-1]) \
: !(*(p) & 0x20) ? ((p) += 2, ((((p)[-2] & 0x1F) << 6) \
| ((p)[-1] & 0x3F))) \
: !(*(p) & 0x10) ? ((p) += 3, ((((p)[-3] & 0x0F) << 12) \
| (((p)[-2] & 0x3F) << 6) \
| ((p)[-1] & 0x3F))) \
: !(*(p) & 0x08) ? ((p) += 4, ((((p)[-4] & 0x07) << 18) \
| (((p)[-3] & 0x3F) << 12) \
| (((p)[-2] & 0x3F) << 6) \
| ((p)[-1] & 0x3F))) \
: !(*(p) & 0x04) ? ((p) += 5, ((((p)[-5] & 0x03) << 24) \
| (((p)[-4] & 0x3F) << 18) \
| (((p)[-3] & 0x3F) << 12) \
| (((p)[-2] & 0x3F) << 6) \
| ((p)[-1] & 0x3F))) \
: ((p) += 6, ((((p)[-6] & 0x01) << 30) \
| (((p)[-5] & 0x3F) << 24) \
| (((p)[-4] & 0x3F) << 18) \
| (((p)[-3] & 0x3F) << 12) \
| (((p)[-2] & 0x3F) << 6) \
| ((p)[-1] & 0x3F))))

## STRING_CHAR_ADVANCE_UTF16

#define STRING_CHAR_ADVANCE_UTF16 | ( |  | p | ) |

Value:
(((p)[0] < 0xD800 || (p)[0] >= 0xDC00) \
? ((p)++, (p)[-1]) \
: ((p) += 2, ((((p)[-2] - 0xD800) << 10) + ((p)[-1] - 0xDC00) + 0x10000)))

## STRING_CHAR_ADVANCE

#define STRING_CHAR_ADVANCE STRING_CHAR_ADVANCE_UTF8

## STRING_CHAR_AND_UNITS_UTF8

#define STRING_CHAR_AND_UNITS_UTF8 | ( |  | p,
|  |  | bytes
| ) |  |

Value:
(!((p)[0] & 0x80) ? ((bytes) = 1, (p)[0]) \
: !((p)[0] & 0x20) ? ((bytes) = 2, \
((((p)[0] & 0x1F) << 6) \
| ((p)[1] & 0x3F))) \
: !((p)[0] & 0x10) ? ((bytes) = 3, \
((((p)[0] & 0x0F) << 12) \
| (((p)[1] & 0x3F) << 6) \
| ((p)[2] & 0x3F))) \
: !((p)[0] & 0x08) ? ((bytes) = 4, \
((((p)[0] & 0x07) << 18) \
| (((p)[1] & 0x3F) << 12) \
| (((p)[2] & 0x3F) << 6) \
| ((p)[3] & 0x3F))) \
: !((p)[0] & 0x04) ? ((bytes) = 5, \
((((p)[0] & 0x03) << 24) \
| (((p)[1] & 0x3F) << 18) \
| (((p)[2] & 0x3F) << 12) \
| (((p)[3] & 0x3F) << 6) \
| ((p)[4] & 0x3F))) \
: ((bytes) = 6, \
((((p)[0] & 0x01) << 30) \
| (((p)[1] & 0x3F) << 24) \
| (((p)[2] & 0x3F) << 18) \
| (((p)[3] & 0x3F) << 12) \
| (((p)[4] & 0x3F) << 6) \
| ((p)[5] & 0x3F))))

## STRING_CHAR_AND_UNITS_UTF16

#define STRING_CHAR_AND_UNITS_UTF16 | ( |  | p,
|  |  | units
| ) |  |

Value:
(((unsigned short) (p)[0] < 0xD800 || (unsigned short) (p)[0] >= 0xDC00) \
? ((units) = 1, (p)[0]) \
: ((units) = 2, \
(((p)[0] - 0xD800) << 10) + ((p)[1] - 0xDC00) + 0x10000))

## STRING_CHAR_AND_UNITS

#define STRING_CHAR_AND_UNITS | ( |  | p,
|  |  | units,
|  |  | format
| ) |  |

Value:
((format) <= MTEXT_FORMAT_UTF_8 \
? STRING_CHAR_AND_UNITS_UTF8 (p, units) \
: (format) <= MTEXT_FORMAT_UTF_16BE \
? STRING_CHAR_AND_UNITS_UTF16 (p, units) \
: ((units) = 1, ((unsigned) (p))[0]))
STRING_CHAR_AND_UNITS_UTF8
#define STRING_CHAR_AND_UNITS_UTF8(p, bytes)
Definition: character.h:111
STRING_CHAR_AND_UNITS_UTF16
#define STRING_CHAR_AND_UNITS_UTF16(p, units)
Definition: character.h:138

## STRING_CHAR_AND_BYTES

#define STRING_CHAR_AND_BYTES STRING_CHAR_AND_UNITS_UTF8

## CHAR_STRING_UTF8

#define CHAR_STRING_UTF8 | ( |  | c,
|  |  | p
| ) |  |

Value:
((c) < 0x80 \
? ((p)[0] = (c), 1) \
: (c) < 0x800 ? ((p)[0] = (0xC0 | ((c) >> 6)), \
(p)[1] = (0x80 | ((c) & 0x3F)), \
2) \
: (c) < 0x10000 ? ((p)[0] = (0xE0 | ((c) >> 12)), \
(p)[1] = (0x80 | (((c) >> 6) & 0x3F)), \
(p)[2] = (0x80 | ((c) & 0x3F)), \
3) \
: (c) < 0x200000 ? ((p)[0] = (0xF0 | ((c) >> 18)), \
(p)[1] = (0x80 | (((c) >> 12) & 0x3F)), \
(p)[2] = (0x80 | (((c) >> 6) & 0x3F)), \
(p)[3] = (0x80 | ((c) & 0x3F)), \
4) \
: (c) < 0x4000000 ? ((p)[0] = 0xF8, \
(p)[1] = (0x80 | ((c) >> 18)), \
(p)[2] = (0x80 | (((c) >> 12) & 0x3F)), \
(p)[3] = (0x80 | (((c) >> 6) & 0x3F)), \
(p)[4] = (0x80 | ((c) & 0x3F)), \
5) \
: ((p)[0] = (0xFC | ((c) >> 30)), \
(p)[1] = (0x80 | (((c) >> 24) & 0x3F)), \
(p)[2] = (0x80 | (((c) >> 18) & 0x3F)), \
(p)[3] = (0x80 | (((c) >> 12) & 0x3F)), \
(p)[4] = (0x80 | (((c) >> 6) & 0x3F)), \
(p)[5] = (0x80 | ((c) & 0x3F)), \
6))

## CHAR_STRING_UTF16

#define CHAR_STRING_UTF16 | ( |  | c,
|  |  | p
| ) |  |

Value:
((c) < 0x10000 ? (p)[0] = (c), 1 \
: (p[0] = (((c) - 0x10000) >> 10) + 0xD800, \
p[1] = (((c) - 0x10000) & 0x3FF) + 0xDC00, \
2))

## CHAR_STRING

#define CHAR_STRING CHAR_STRING_UTF8

## CHAR_HEAD_P_UTF8

#define CHAR_HEAD_P_UTF8 | ( |  | p | ) | ((*(p) & 0xC0) != 0x80)

## CHAR_HEAD_P_UTF16

#define CHAR_HEAD_P_UTF16 | ( |  | p | ) |

Value:
(*(unsigned short *) (p) < 0xDC00 \
|| *(unsigned short *) (p) >= 0xE000)

## CHAR_HEAD_P

#define CHAR_HEAD_P CHAR_HEAD_P_UTF8

## TOLOWER

#define TOLOWER | ( |  | c | ) | (((c) >= 'A' && (c) <= 'Z') ? (c) + 32 : (c))

## TOUPPER

#define TOUPPER | ( |  | c | ) | (((c) >= 'a' && (c) <= 'z') ? (c) - 32 : (c))

## ISUPPER

#define ISUPPER | ( |  | c | ) | ((c) >= 'A' && (c) <= 'Z')

## ISALNUM

#define ISALNUM | ( |  | c | ) |

Value:
(((c) >= 'A' && (c) <= 'Z') \
|| ((c) >= 'a' && (c) <= 'z') \
|| ((c) >= '0' && (c) <= '9'))

## Function Documentation

## mchar__define_prop()

void mchar__define_prop | ( | MSymbol | key,
|  | MSymbol | type,
|  | void * | mdb
| ) |  |