From 9e66bab34b88f992803d137fab0637950c3123a5 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 1 Dec 2023 10:42:42 +0800 Subject: [PATCH] fix https://github.com/blueloveTH/pocketpy/issues/179 --- include/pocketpy/str.h | 1 + src/str.cpp | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/pocketpy/str.h b/include/pocketpy/str.h index cad7efc5..f7cf8b87 100644 --- a/include/pocketpy/str.h +++ b/include/pocketpy/str.h @@ -26,6 +26,7 @@ struct Str{ Str(std::nullptr_t) { FATAL_ERROR(); } Str(const char* s); Str(const char* s, int len); + Str(std::pair); Str(const Str& other); Str(Str&& other); diff --git a/src/str.cpp b/src/str.cpp index 7eb884f8..91a7865a 100644 --- a/src/str.cpp +++ b/src/str.cpp @@ -42,6 +42,19 @@ int utf8len(unsigned char c, bool suppress){ #undef STR_INIT + Str::Str(std::pair detached) { + this->size = detached.second; + this->data = detached.first; + this->is_ascii = true; + // check is_ascii + for(int i=0; i