| 2 | #include "3ds/util/utf.h" |
| 3 | |
| 4 | ssize_t |
| 5 | utf8_to_utf32(uint32_t *out, |
| 6 | const uint8_t *in, |
| 7 | size_t len) |
| 8 | { |
| 9 | ssize_t rc = 0; |
| 10 | ssize_t units; |
| 11 | uint32_t code; |
| 12 | |
| 13 | do |
| 14 | { |
| 15 | units = decode_utf8(&code, in); |
| 16 | if(units == -1) |
| 17 | return -1; |
| 18 | |
| 19 | if(code > 0) |
| 20 | { |
| 21 | in += units; |
| 22 | |
| 23 | if(out != NULL) |
| 24 | { |
| 25 | if(rc < len) |
| 26 | *out++ = code; |
| 27 | } |
| 28 | |
| 29 | if(SSIZE_MAX - 1 >= rc) |
| 30 | ++rc; |
| 31 | else |
| 32 | return -1; |
| 33 | } |
| 34 | } while(code > 0); |
| 35 | |
| 36 | return rc; |
| 37 | } |
nothing calls this directly
no test coverage detected