mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Refactor readUTF8Char into charmap_ConvertNext
This commit is contained in:
23
src/util.cpp
23
src/util.cpp
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user