From aa13090b66d7ee1ffc68ad242c6419a83cf364d9 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Wed, 12 Dec 2012 11:25:58 +0000 Subject: started an official API to the C runtime --- src/runtime/c/gu/ucs.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/runtime/c/gu/ucs.c') diff --git a/src/runtime/c/gu/ucs.c b/src/runtime/c/gu/ucs.c index dc210b312..42012e3e0 100644 --- a/src/runtime/c/gu/ucs.c +++ b/src/runtime/c/gu/ucs.c @@ -1,6 +1,6 @@ #include #include -#include +#include "config.h" GU_DEFINE_TYPE(GuUCSExn, abstract, _); @@ -131,5 +131,16 @@ gu_ucs_to_str(const GuUCS* ubuf, size_t len, char* cbuf, GuExn* err) extern inline bool gu_ucs_valid(GuUCS ucs); -extern inline GuUCS -gu_char_ucs(char c); +GuUCS +gu_char_ucs(char c) +{ + gu_require(gu_char_is_valid(c)); +#ifdef CHAR_ASCII + GuUCS u = (GuUCS) c; +#else + extern const uint8_t gu_ucs_ascii_reverse_[CHAR_MAX]; + GuUCS u = gu_ucs_ascii_reverse_[(unsigned char) c]; +#endif + gu_ensure(u < 0x80); + return u; +} -- cgit v1.2.3