Files
fx/core/include/fx/core/encoding.h
2026-03-16 10:35:43 +00:00

42 lines
1.2 KiB
C

#ifndef FX_CORE_ENCODING_H_
#define FX_CORE_ENCODING_H_
#include <fx/core/misc.h>
#include <stdbool.h>
#include <stdint.h>
#define FX_WCHAR_INVALID ((fx_wchar) - 1)
typedef int32_t fx_wchar;
FX_API bool fx_wchar_is_alpha(fx_wchar c);
FX_API bool fx_wchar_is_number(fx_wchar c);
static inline bool fx_wchar_is_bin_digit(fx_wchar c)
{
return c >= '0' && c <= '1';
}
static inline bool fx_wchar_is_oct_digit(fx_wchar c)
{
return c >= '0' && c <= '7';
}
FX_API bool fx_wchar_is_hex_digit(fx_wchar c);
FX_API bool fx_wchar_is_space(fx_wchar c);
static inline bool fx_wchar_is_alnum(fx_wchar c)
{
return fx_wchar_is_alpha(c) || fx_wchar_is_number(c);
}
FX_API bool fx_wchar_is_punct(fx_wchar c);
FX_API bool fx_wchar_utf8_is_valid_scalar(fx_wchar c);
FX_API unsigned int fx_wchar_utf8_header_decode(char c);
FX_API unsigned int fx_wchar_utf8_codepoint_size(fx_wchar c);
FX_API fx_wchar fx_wchar_utf8_codepoint_decode(const char *s);
FX_API unsigned int fx_wchar_utf8_codepoint_encode(fx_wchar c, char s[4]);
FX_API unsigned int fx_wchar_utf8_codepoint_stride(const char *s);
FX_API size_t fx_wchar_utf8_codepoint_count(const char *s, size_t nr_bytes);
FX_API size_t fx_wchar_utf8_string_encoded_size(
const fx_wchar *s, size_t nr_codepoints);
#endif