46 lines
1.3 KiB
C
46 lines
1.3 KiB
C
#ifndef BLUE_CORE_ENCODING_H_
|
|
#define BLUE_CORE_ENCODING_H_
|
|
|
|
#include <blue/core/misc.h>
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
B_DECLS_BEGIN;
|
|
|
|
#define B_WCHAR_INVALID ((b_wchar) - 1)
|
|
|
|
typedef int32_t b_wchar;
|
|
|
|
BLUE_API bool b_wchar_is_alpha(b_wchar c);
|
|
BLUE_API bool b_wchar_is_number(b_wchar c);
|
|
static inline bool b_wchar_is_bin_digit(b_wchar c)
|
|
{
|
|
return c >= '0' && c <= '1';
|
|
}
|
|
static inline bool b_wchar_is_oct_digit(b_wchar c)
|
|
{
|
|
return c >= '0' && c <= '7';
|
|
}
|
|
BLUE_API bool b_wchar_is_hex_digit(b_wchar c);
|
|
BLUE_API bool b_wchar_is_space(b_wchar c);
|
|
static inline bool b_wchar_is_alnum(b_wchar c)
|
|
{
|
|
return b_wchar_is_alpha(c) || b_wchar_is_number(c);
|
|
}
|
|
|
|
BLUE_API bool b_wchar_is_punct(b_wchar c);
|
|
|
|
BLUE_API bool b_wchar_utf8_is_valid_scalar(b_wchar c);
|
|
BLUE_API unsigned int b_wchar_utf8_header_decode(char c);
|
|
BLUE_API unsigned int b_wchar_utf8_codepoint_size(b_wchar c);
|
|
BLUE_API b_wchar b_wchar_utf8_codepoint_decode(const char *s);
|
|
BLUE_API unsigned int b_wchar_utf8_codepoint_encode(b_wchar c, char s[4]);
|
|
BLUE_API unsigned int b_wchar_utf8_codepoint_stride(const char *s);
|
|
BLUE_API size_t b_wchar_utf8_codepoint_count(const char *s, size_t nr_bytes);
|
|
BLUE_API size_t b_wchar_utf8_string_encoded_size(
|
|
const b_wchar *s, size_t nr_codepoints);
|
|
|
|
B_DECLS_END;
|
|
|
|
#endif
|