diff --git a/test.c b/test.c index f3693d80..2d86b1a2 100644 --- a/test.c +++ b/test.c @@ -37,6 +37,12 @@ uint32_t Cyc_utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte) { return *state; } +/** + * Simple macro to make it more convenient to convert a single char + */ +#define Cyc_utf8_encode_char(dest, dest_size, char_value) \ + Cyc_utf8_encode(dest, dest_size, &char_value, 1) + /** * This function takes one or more 32-bit chars and encodes them * as an array of UTF-8 bytes. @@ -102,7 +108,7 @@ void encode(uint32_t val) { char dest[5]; int rv, i; - rv = Cyc_utf8_encode(dest, 5, &val, 1); + rv = Cyc_utf8_encode_char(dest, 5, val); printf("%x %d \n", val, rv); for(i = 0; i < 5; i++) { printf("[%x] ", (uint8_t)dest[i]);