begin of testing

This commit is contained in:
2026-07-19 14:45:49 -06:00
parent 29784ea152
commit 09d117debf
2 changed files with 20 additions and 3 deletions
+15
View File
@@ -1,5 +1,8 @@
#include <iostream> #include <iostream>
#include <spider/compiler/common.hpp>
#include <spider/compiler/text/utf8.hpp>
namespace spider { namespace spider {
@@ -7,6 +10,18 @@ namespace spider {
} }
int main() { 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; std::cout << "Happy Day!" << std::endl;
return 0; return 0;
} }
+5 -3
View File
@@ -86,10 +86,11 @@ namespace spider {
return out; return out;
} }
inline bool charAt(const std::string& str, isize& index, u32& out) { inline bool charAt(std::string_view str, isize& index, u32& out) {
isize chlen = isValidSeq(str.c_str(), str.size()); isize chlen = isValidSeq(str.begin(), str.size());
if(chlen == 0) return false; if(chlen == 0) return false;
out = decodeArr(str.c_str(), chlen); out = decodeArr(str.begin(), chlen);
index += chlen;
return true; return true;
} }
@@ -103,6 +104,7 @@ namespace spider {
_size = isValidSeq(cptr + _i, csize - _i); _size = isValidSeq(cptr + _i, csize - _i);
if(_size == 0) return false; if(_size == 0) return false;
out += decodeArr(cptr + _i, _size); out += decodeArr(cptr + _i, _size);
_i += _size;
} }
return _i == csize; return _i == csize;