begin of testing
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include <iostream>
|
||||
|
||||
#include <spider/compiler/common.hpp>
|
||||
#include <spider/compiler/text/utf8.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user