Refactor readUTF8Char into charmap_ConvertNext

This commit is contained in:
Rangi42
2025-01-28 00:04:49 -05:00
parent 34a9c8e083
commit e49291b7cf
4 changed files with 23 additions and 38 deletions

View File

@@ -5,9 +5,6 @@
#include <ctype.h>
#include <stdint.h>
#include <stdio.h>
#include <vector>
#include "extern/utf8decoder.hpp"
char const *printChar(int c) {
// "'A'" + '\0': 4 bytes
@@ -53,23 +50,3 @@ char const *printChar(int c) {
buf[4] = '\0';
return buf;
}
size_t readUTF8Char(std::vector<int32_t> *dest, char const *src) {
uint32_t state = 0, codepoint;
size_t i = 0;
for (;;) {
if (decode(&state, &codepoint, src[i]) == 1) {
return 0;
}
if (dest) {
dest->push_back(src[i]);
}
i++;
if (state == 0) {
return i;
}
}
}