fix: fix build error in Linux environment.

- fix various build error in Linux environment.
- the convertion between UTF8, UTF16 and UTF32 have error in Linux and will be fixed in future.
This commit is contained in:
yyc12345 2024-06-19 13:28:51 +08:00
parent b61f718084
commit 1fd132f0c9
3 changed files with 18 additions and 13 deletions

View File

@ -171,7 +171,7 @@ namespace YYCC::ConsoleHelper {
#else
// just return true and do nothing
return true
return true;
#endif
}
@ -226,7 +226,7 @@ namespace YYCC::ConsoleHelper {
WinConsoleWrite(strl, bIsErr);
#else
// in linux, directly use C function to write.
std::fputs(strl.c_str(), to_stderr ? stderr : stdout);
std::fputs(strl.c_str(), bIsErr ? stderr : stdout);
#endif
}
@ -245,11 +245,13 @@ namespace YYCC::ConsoleHelper {
}
void Write(const char* u8_strl) {
RawWrite<false, false, false>(u8_strl, va_list());
va_list empty;
RawWrite<false, false, false>(u8_strl, empty);
}
void WriteLine(const char* u8_strl) {
RawWrite<false, false, true>(u8_strl, va_list());
va_list empty;
RawWrite<false, false, true>(u8_strl, empty);
}
void ErrFormat(const char* u8_fmt, ...) {
@ -267,11 +269,13 @@ namespace YYCC::ConsoleHelper {
}
void ErrWrite(const char* u8_strl) {
RawWrite<false, true, false>(u8_strl, va_list());
va_list empty;
RawWrite<false, true, false>(u8_strl, empty);
}
void ErrWriteLine(const char* u8_strl) {
RawWrite<false, true, true>(u8_strl, va_list());
va_list empty;
RawWrite<false, true, true>(u8_strl, empty);
}
}

View File

@ -1,6 +1,7 @@
#include "EncodingHelper.hpp"
#include <cuchar>
#include <climits>
namespace YYCC::EncodingHelper {

View File

@ -23,7 +23,7 @@ namespace YYCCTestbench {
#define TEST_UNICODE_STR_EMOJI "\U0001F363 \u2716 \U0001F37A" // sushi x beer mug
#define CONCAT(prefix, strl) prefix ## strl
#define CPP_U8_LITERAL(strl) strl
#define CPP_U8_LITERAL(strl) reinterpret_cast<const char*>(CONCAT(u8, strl))
#define CPP_U16_LITERAL(strl) CONCAT(u, strl)
#define CPP_U32_LITERAL(strl) CONCAT(U, strl)
#define CPP_WSTR_LITERAL(strl) CONCAT(L, strl)
@ -394,10 +394,10 @@ namespace YYCCTestbench {
int main(int argc, char** args) {
//YYCCTestbench::ConsoleTestbench();
YYCCTestbench::EncodingTestbench();
//YYCCTestbench::StringTestbench();
//YYCCTestbench::ParserTestbench();
//YYCCTestbench::DialogTestbench();
//YYCCTestbench::ExceptionTestbench();
//YYCCTestbench::WinFctTestbench();
//YYCCTestbench::FsPathPatch();
YYCCTestbench::StringTestbench();
YYCCTestbench::ParserTestbench();
YYCCTestbench::DialogTestbench();
YYCCTestbench::ExceptionTestbench();
YYCCTestbench::WinFctTestbench();
YYCCTestbench::FsPathPatch();
}