meta: rename to fx
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#include <blue/core/encoding.h>
|
||||
#include <fx/core/encoding.h>
|
||||
#include <wctype.h>
|
||||
|
||||
bool b_wchar_is_number(b_wchar c)
|
||||
bool fx_wchar_is_number(fx_wchar c)
|
||||
{
|
||||
return iswnumber((wchar_t)c);
|
||||
}
|
||||
|
||||
bool b_wchar_is_alpha(b_wchar c)
|
||||
bool fx_wchar_is_alpha(fx_wchar c)
|
||||
{
|
||||
if (c == 0) {
|
||||
return false;
|
||||
@@ -1177,28 +1177,28 @@ bool b_wchar_is_alpha(b_wchar c)
|
||||
}
|
||||
}
|
||||
|
||||
bool b_wchar_is_hex_digit(b_wchar c)
|
||||
bool fx_wchar_is_hex_digit(fx_wchar c)
|
||||
{
|
||||
return isxdigit(c);
|
||||
}
|
||||
|
||||
bool b_wchar_is_space(b_wchar c)
|
||||
bool fx_wchar_is_space(fx_wchar c)
|
||||
{
|
||||
return iswspace((wchar_t)c);
|
||||
}
|
||||
|
||||
bool b_wchar_is_punct(b_wchar c)
|
||||
bool fx_wchar_is_punct(fx_wchar c)
|
||||
{
|
||||
return iswpunct((wchar_t)c);
|
||||
}
|
||||
|
||||
bool b_wchar_utf8_is_valid_scalar(b_wchar c)
|
||||
bool fx_wchar_utf8_is_valid_scalar(fx_wchar c)
|
||||
{
|
||||
return (((c) >= 0x0000 && (c) <= 0xD7FF)
|
||||
|| ((c) >= 0xE000 && (c) <= 0x10FFFF));
|
||||
}
|
||||
|
||||
unsigned int b_wchar_utf8_header_decode(char c)
|
||||
unsigned int fx_wchar_utf8_header_decode(char c)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
|
||||
@@ -1217,9 +1217,9 @@ unsigned int b_wchar_utf8_header_decode(char c)
|
||||
return len;
|
||||
}
|
||||
|
||||
unsigned int b_wchar_utf8_codepoint_size(b_wchar c)
|
||||
unsigned int fx_wchar_utf8_codepoint_size(fx_wchar c)
|
||||
{
|
||||
if (!b_wchar_utf8_is_valid_scalar(c)) {
|
||||
if (!fx_wchar_utf8_is_valid_scalar(c)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1251,9 +1251,9 @@ static int32_t decode_utf8_trailer_byte(char c)
|
||||
return c & 0x3F;
|
||||
}
|
||||
|
||||
b_wchar b_wchar_utf8_codepoint_decode(const char *s)
|
||||
fx_wchar fx_wchar_utf8_codepoint_decode(const char *s)
|
||||
{
|
||||
b_wchar result = 0;
|
||||
fx_wchar result = 0;
|
||||
int len = 0;
|
||||
|
||||
if (!(s[0] & 0x80)) {
|
||||
@@ -1272,29 +1272,29 @@ b_wchar b_wchar_utf8_codepoint_decode(const char *s)
|
||||
result = s[0] & 0x07;
|
||||
result <<= 18;
|
||||
} else {
|
||||
return B_WCHAR_INVALID;
|
||||
return FX_WCHAR_INVALID;
|
||||
}
|
||||
|
||||
for (int i = 1; i < len; i++) {
|
||||
int32_t c = decode_utf8_trailer_byte(s[i]);
|
||||
if (c == -1) {
|
||||
return B_WCHAR_INVALID;
|
||||
return FX_WCHAR_INVALID;
|
||||
}
|
||||
|
||||
c <<= 6 * (len - i - 1);
|
||||
result |= c;
|
||||
}
|
||||
|
||||
if (!b_wchar_utf8_is_valid_scalar(result)) {
|
||||
return B_WCHAR_INVALID;
|
||||
if (!fx_wchar_utf8_is_valid_scalar(result)) {
|
||||
return FX_WCHAR_INVALID;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
unsigned int b_wchar_utf8_codepoint_encode(b_wchar c, char s[4])
|
||||
unsigned int fx_wchar_utf8_codepoint_encode(fx_wchar c, char s[4])
|
||||
{
|
||||
unsigned int len = b_wchar_utf8_codepoint_size(c);
|
||||
unsigned int len = fx_wchar_utf8_codepoint_size(c);
|
||||
|
||||
switch (len) {
|
||||
case 1:
|
||||
@@ -1322,7 +1322,7 @@ unsigned int b_wchar_utf8_codepoint_encode(b_wchar c, char s[4])
|
||||
return len;
|
||||
}
|
||||
|
||||
unsigned int b_wchar_utf8_codepoint_stride(const char *s)
|
||||
unsigned int fx_wchar_utf8_codepoint_stride(const char *s)
|
||||
{
|
||||
char c = *s;
|
||||
|
||||
@@ -1345,13 +1345,13 @@ unsigned int b_wchar_utf8_codepoint_stride(const char *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t b_wchar_utf8_codepoint_count(const char *s, size_t nr_bytes)
|
||||
size_t fx_wchar_utf8_codepoint_count(const char *s, size_t nr_bytes)
|
||||
{
|
||||
size_t nr_codepoints = 0;
|
||||
const char *end = s + nr_bytes;
|
||||
|
||||
while (*s && s < end) {
|
||||
size_t stride = b_wchar_utf8_codepoint_stride(s);
|
||||
size_t stride = fx_wchar_utf8_codepoint_stride(s);
|
||||
if (stride == 0) {
|
||||
/* invalid codepoint */
|
||||
return 0;
|
||||
@@ -1364,11 +1364,11 @@ size_t b_wchar_utf8_codepoint_count(const char *s, size_t nr_bytes)
|
||||
return nr_codepoints;
|
||||
}
|
||||
|
||||
size_t b_wchar_utf8_string_encoded_size(const b_wchar *s, size_t nr_codepoints)
|
||||
size_t fx_wchar_utf8_string_encoded_size(const fx_wchar *s, size_t nr_codepoints)
|
||||
{
|
||||
size_t len = 0;
|
||||
for (size_t i = 0; i < nr_codepoints; i++) {
|
||||
size_t l = b_wchar_utf8_codepoint_size(s[i]);
|
||||
size_t l = fx_wchar_utf8_codepoint_size(s[i]);
|
||||
if (l == 0) {
|
||||
/* invalid codepoint */
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user