This question may be a little old, but I would like to touch on the implementation of your functions with char16_t and char32_t support.
The easiest way to do this is to write your strtoull function using char32_t type (call it something like strtoull_c32 ). This simplifies Unicode parsing because each character in UTF-32 takes up four bytes. Then do strtoull_c16 and strtoull_c8 , internally converting the UTF-8 and UTF-16 UTF-32 to UTF-32 and passing them to strtoull_c32 .
I honestly did not look at Unicode objects in the C11 standard library, but if they do not provide a suitable way to convert these types to UTF-32 , then you can use a third-party library to do the conversion for you.
There is an ICU that was launched by IBM and then adopted by the Unicode Consortium. This is a very multifunctional and stable library that has existed for a long time.
I recently launched the UTF library ( UTFX ) for C89, which you could use to do this. This is a fairly simple and easy, tested and documented unit. You can give this or use it to find out more about how UTF conversions work.
source share