From 5aaf9d5229f69ba23a8f0caa149d34d977b791ed Mon Sep 17 00:00:00 2001 From: DolphyWind Date: Fri, 23 Feb 2024 18:48:48 +0300 Subject: [PATCH] Change a tiny aspect about how file reader works --- README.md | 2 +- include/ArgParser.hpp | 2 +- src/FileReader.cpp | 5 +---- src/Printer.cpp | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b3b49e6..2ec9450 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,7 @@ Supports all eight directions. Finishes the program execution. ### **File Reader (r)** Supports northeast, north, northwest, west and southwest directions. Continuously pops the value on top of the stack and constructs a filename from those values until either it hits a zero or the stack becomes empty. (If it hits a zero, it also pops that) -Then reads the file with that filename in binary mode with utf8 encoding and pushes its content on top of the stack in reverse order, meaning the first character of the file will be the value on top of the stack. If it fails, it pushes zero to the stack. +Then reads the file with that filename in binary mode and pushes its content on top of the stack in reverse order, meaning the first character of the file will be the value on top of the stack. If it fails, it pushes zero to the stack. ### **File Openers** Similar to File Reader, File Openers read a filename from the stack in the same way. After opening the file, they push a positive integer as unique identifier that can be used to communicate with file. diff --git a/include/ArgParser.hpp b/include/ArgParser.hpp index 550d09e..c89397d 100644 --- a/include/ArgParser.hpp +++ b/include/ArgParser.hpp @@ -26,7 +26,7 @@ SOFTWARE. #define ELECTRA_VERSION_MAJOR 2 #define ELECTRA_VERSION_MINOR 2 -#define ELECTRA_VERSION_PATCH 0 +#define ELECTRA_VERSION_PATCH 1 #include #include diff --git a/src/FileReader.cpp b/src/FileReader.cpp index a77087c..9796e9c 100644 --- a/src/FileReader.cpp +++ b/src/FileReader.cpp @@ -62,10 +62,7 @@ bool FileReader::work(Current::Ptr current, std::vector& currentVe std::stringstream ss; ss << ifs.rdbuf(); ifs.close(); - std::string fileContent_utf8 = ss.str(); - std::u32string fileContent; - fileContent.reserve(fileContent_utf8.size()); - utf8::utf8to32(fileContent_utf8.begin(), fileContent_utf8.end(), std::back_inserter(fileContent)); + std::string fileContent = ss.str(); while(!fileContent.empty()) { diff --git a/src/Printer.cpp b/src/Printer.cpp index 771e8a2..55cac86 100644 --- a/src/Printer.cpp +++ b/src/Printer.cpp @@ -55,7 +55,7 @@ bool Printer::work(Current::Ptr current, std::vector& currentVecto } catch(const utf8::invalid_code_point& invalidCodePoint) { - defaultLogger.log(LogType::WARNING, "{}. {}", invalidCodePoint.what(), static_cast(top_character32)); + std::cout << static_cast(top_character32); } std::cout << str_to_print << std::flush;