From 09d117debf1a1bde32073445f2d9dcb7e5f09695 Mon Sep 17 00:00:00 2001 From: Kittycannon Date: Sun, 19 Jul 2026 14:45:49 -0600 Subject: [PATCH] begin of testing --- src/spider/compiler/Compiler.cpp | 15 +++++++++++++++ src/spider/compiler/text/utf8.hpp | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/spider/compiler/Compiler.cpp b/src/spider/compiler/Compiler.cpp index 6654941..ed21b53 100644 --- a/src/spider/compiler/Compiler.cpp +++ b/src/spider/compiler/Compiler.cpp @@ -1,5 +1,8 @@ #include +#include +#include + namespace spider { @@ -7,6 +10,18 @@ namespace spider { } int main() { + std::string test = "UTF-STR WITH EMOJIS 😀🚀"; + // Extracted UTF-8 chars: + std::u32string out; + bool r = spider::utf8::toUTF32(test, out); + + std::cout << "INPUT: " << test << std::endl; + std::cout << "RESULT: " << int(r) << std::endl; + for(spider::u32 ch : out) { + std::cout << ch << " "; + } + std::cout << std::endl; + std::cout << "Happy Day!" << std::endl; return 0; } diff --git a/src/spider/compiler/text/utf8.hpp b/src/spider/compiler/text/utf8.hpp index 7e1a896..d230442 100644 --- a/src/spider/compiler/text/utf8.hpp +++ b/src/spider/compiler/text/utf8.hpp @@ -86,10 +86,11 @@ namespace spider { return out; } - inline bool charAt(const std::string& str, isize& index, u32& out) { - isize chlen = isValidSeq(str.c_str(), str.size()); + inline bool charAt(std::string_view str, isize& index, u32& out) { + isize chlen = isValidSeq(str.begin(), str.size()); if(chlen == 0) return false; - out = decodeArr(str.c_str(), chlen); + out = decodeArr(str.begin(), chlen); + index += chlen; return true; } @@ -103,6 +104,7 @@ namespace spider { _size = isValidSeq(cptr + _i, csize - _i); if(_size == 0) return false; out += decodeArr(cptr + _i, _size); + _i += _size; } return _i == csize;