mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-08 13:37:33 +02:00
WIP
This commit is contained in:
parent
96c3846b43
commit
ccfde220ff
1 changed files with 7 additions and 1 deletions
8
test.c
8
test.c
|
@ -37,6 +37,12 @@ uint32_t Cyc_utf8_decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
|
||||||
return *state;
|
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
|
* This function takes one or more 32-bit chars and encodes them
|
||||||
* as an array of UTF-8 bytes.
|
* as an array of UTF-8 bytes.
|
||||||
|
@ -102,7 +108,7 @@ void encode(uint32_t val) {
|
||||||
char dest[5];
|
char dest[5];
|
||||||
int rv, i;
|
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);
|
printf("%x %d \n", val, rv);
|
||||||
for(i = 0; i < 5; i++) {
|
for(i = 0; i < 5; i++) {
|
||||||
printf("[%x] ", (uint8_t)dest[i]);
|
printf("[%x] ", (uint8_t)dest[i]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue