From 6e13571f607068e94b61704ae10949c9aa093bac Mon Sep 17 00:00:00 2001 From: Kittcannon Date: Sat, 26 Sep 2026 22:21:12 -0600 Subject: [PATCH] unicode --- src/spider/compiler/Compiler.cpp | 4 ++-- src/spider/compiler/text/TextReader.cpp | 8 ++++---- src/spider/compiler/text/Token.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/spider/compiler/Compiler.cpp b/src/spider/compiler/Compiler.cpp index 2879e91..b86fa33 100644 --- a/src/spider/compiler/Compiler.cpp +++ b/src/spider/compiler/Compiler.cpp @@ -20,7 +20,7 @@ static bool run_test_case(const Token* token, const std::string& input, bool exp if (status_ok && match_ok) { std::cout << "[PASS] Input: \"" << input << "\" -> " << (res.success ? "SUCCESS" : "FAILURE") - << (res.success ? (" (Matched: \"" + utf8::toUTF8(res.flatMatch()) + "\")") : "") + << (res.success ? (" (Matched: \"" + unicode::toUTF8(res.flatMatch()) + "\")") : "") << "\n"; return true; } @@ -28,7 +28,7 @@ static bool run_test_case(const Token* token, const std::string& input, bool exp std::cerr << "[FAIL] Input: \"" << input << "\"\n" << " Expected Success: " << (expectedSuccess ? "true" : "false") << ", Got: " << (res.success ? "true" : "false") << "\n"; if (expectedSuccess && !expectedMatch.empty()) { - std::cerr << " Expected Match: \"" << utf8::toUTF8(expectedMatch) << "\", Got: \"" << utf8::toUTF8(res.flatMatch()) << "\"\n"; + std::cerr << " Expected Match: \"" << unicode::toUTF8(expectedMatch) << "\", Got: \"" << unicode::toUTF8(res.flatMatch()) << "\"\n"; } return false; } diff --git a/src/spider/compiler/text/TextReader.cpp b/src/spider/compiler/text/TextReader.cpp index 6f157ca..13c0542 100644 --- a/src/spider/compiler/text/TextReader.cpp +++ b/src/spider/compiler/text/TextReader.cpp @@ -1,6 +1,6 @@ #include "TextReader.hpp" -#include +#include #include @@ -28,7 +28,7 @@ namespace spider { // instead of whatever that was, convert to UTF-32 // and then do an easy compare! std::u32string str; - if(!utf8::toUTF32(chars, str)) throw std::runtime_error("Specified invalid UTF-8 string!"); + if(!unicode::toUTF32(chars, str)) throw std::runtime_error("Specified invalid UTF-8 string!"); return eat(str); } @@ -143,7 +143,7 @@ namespace spider { if (err) return false; if (eof) return false; - isize chsize = utf8::seqlen(u8(bytes[bindex])); + isize chsize = unicode::seqlen(u8(bytes[bindex])); if(chsize == 0) { err = true; errmsg = "Invalid start of UTF-8 sequence."; @@ -158,7 +158,7 @@ namespace spider { } u32 decodedChar; - if(!utf8::decodeArr(bytes, chsize, decodedChar)) { + if(!unicode::decodeArr(bytes, chsize, decodedChar)) { err = true; errmsg = "Invalid UTF-8 sequence."; return false; diff --git a/src/spider/compiler/text/Token.cpp b/src/spider/compiler/text/Token.cpp index 472316c..4f8d53c 100644 --- a/src/spider/compiler/text/Token.cpp +++ b/src/spider/compiler/text/Token.cpp @@ -87,7 +87,7 @@ namespace spider { // ============================================================================ LitToken::LitToken(std::string_view lit) { - if (!utf8::toUTF32(lit, literal)) throw std::runtime_error("Illegal UTF8 literal!"); + if (!unicode::toUTF32(lit, literal)) throw std::runtime_error("Illegal UTF8 literal!"); } LitToken::LitToken(std::u32string lit) : literal(std::move(lit)) {} @@ -116,7 +116,7 @@ namespace spider { } r.success = !r.match.empty(); - if(r.success) std::cout << "[fn] matched: " << utf8::toUTF8(r.flatMatch()) << std::endl; + if(r.success) std::cout << "[fn] matched: " << unicode::toUTF8(r.flatMatch()) << std::endl; return r; } @@ -166,7 +166,7 @@ namespace spider { // Short-circuit branch: return immediately on first valid choice match TokenResult res = token_ref->test(ctx); if (res.success) { - std::cout << "[or] matched: " << utf8::toUTF8(res.flatMatch()) << std::endl; + std::cout << "[or] matched: " << unicode::toUTF8(res.flatMatch()) << std::endl; return res; } @@ -188,7 +188,7 @@ namespace spider { TokenResult res = target->test(ctx); if (res.success) { - std::cout << "[~] matched: " << utf8::toUTF8(res.flatMatch()) << std::endl; + std::cout << "[~] matched: " << unicode::toUTF8(res.flatMatch()) << std::endl; return res; // Option matched exactly 1 instance successfully } @@ -225,7 +225,7 @@ namespace spider { // Repetition rules (* token) always evaluate to successful // completion state, even with 0 matches. r.success = true; - std::cout << "[*] matched: " << utf8::toUTF8(r.flatMatch()) << std::endl; + std::cout << "[*] matched: " << unicode::toUTF8(r.flatMatch()) << std::endl; return r; }