mirror of
https://github.com/NeoFlock/neonucleus.git
synced 2025-09-24 09:03:32 +02:00
Implement nn_unicode_wlen
This commit is contained in:
parent
0ef58c1458
commit
5aae180c18
@ -8,7 +8,6 @@ static bool nn_unicode_is_continuation(unsigned char byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool nn_unicode_validate(const char *b) {
|
bool nn_unicode_validate(const char *b) {
|
||||||
// TODO: validate UTF-8-ness
|
|
||||||
const unsigned char* s = (const unsigned char*)b;
|
const unsigned char* s = (const unsigned char*)b;
|
||||||
while (*s) {
|
while (*s) {
|
||||||
if(s[0] <= 0x7F) {
|
if(s[0] <= 0x7F) {
|
||||||
@ -168,12 +167,24 @@ const char *nn_unicode_codepointToChar(unsigned int codepoint, size_t *len) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t nn_unicode_charWidth(unsigned int codepoint) {
|
||||||
|
// TODO: implement this
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t nn_unicode_wlen(const char *s) {
|
||||||
|
size_t wlen = 0;
|
||||||
|
while (*s) {
|
||||||
|
unsigned int codepoint = nn_unicode_codepointAt(s, 0);
|
||||||
|
size_t codepointSize = nn_unicode_codepointSize(codepoint);
|
||||||
|
wlen += nn_unicode_charWidth(codepoint);
|
||||||
|
s += codepointSize;
|
||||||
|
}
|
||||||
|
return wlen;
|
||||||
|
}
|
||||||
|
|
||||||
// NOT IMPLEMENTED YET
|
// NOT IMPLEMENTED YET
|
||||||
|
|
||||||
size_t nn_unicode_charWidth(unsigned int codepoint);
|
|
||||||
|
|
||||||
size_t nn_unicode_wlen(const char *s);
|
|
||||||
|
|
||||||
unsigned int nn_unicode_upperCodepoint(unsigned int codepoint);
|
unsigned int nn_unicode_upperCodepoint(unsigned int codepoint);
|
||||||
char *nn_unicode_upper(const char *s);
|
char *nn_unicode_upper(const char *s);
|
||||||
unsigned int nn_unicode_lowerCodepoint(unsigned int codepoint);
|
unsigned int nn_unicode_lowerCodepoint(unsigned int codepoint);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user