diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2012-12-12 11:25:58 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2012-12-12 11:25:58 +0000 |
| commit | aa13090b66d7ee1ffc68ad242c6419a83cf364d9 (patch) | |
| tree | d36bacbc5f4e0990aae925da31ddeaf2a465a003 /src/runtime/c/gu/ucs.c | |
| parent | 5e091d2e3dc428daa1d4b0d8df6e7b613adc22a9 (diff) | |
started an official API to the C runtime
Diffstat (limited to 'src/runtime/c/gu/ucs.c')
| -rw-r--r-- | src/runtime/c/gu/ucs.c | 17 |
1 files changed, 14 insertions, 3 deletions
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 <gu/ucs.h> #include <gu/assert.h> -#include <config.h> +#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; +} |
