TextConsole: Add wide-character overloads for print() and println()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
These can't fail from UTF-8 decoding errors.
This commit is contained in:
parent
293b7b0f11
commit
fcefab4383
@ -58,16 +58,7 @@ static void log_text_console(LogLevel level, const char* format, va_list origin)
|
|||||||
auto rc = cstyle_format(
|
auto rc = cstyle_format(
|
||||||
format, [](char c, void*) -> Result<void> { return TextConsole::putchar(c); }, nullptr, ap);
|
format, [](char c, void*) -> Result<void> { return TextConsole::putchar(c); }, nullptr, ap);
|
||||||
|
|
||||||
if (rc.has_error())
|
if (rc.has_error()) { TextConsole::wprint(L"Invalid UTF-8 in log message"); }
|
||||||
{
|
|
||||||
// FIXME: Find a way to do this in a simpler way (TextConsole::wprint maybe?)
|
|
||||||
const wchar_t* s = L"Invalid UTF-8 in log message";
|
|
||||||
while (*s)
|
|
||||||
{
|
|
||||||
TextConsole::putwchar(*s);
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TextConsole::putwchar(L'\n');
|
TextConsole::putwchar(L'\n');
|
||||||
|
|
||||||
|
@ -172,6 +172,11 @@ namespace TextConsole
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wprint(const wchar_t* str)
|
||||||
|
{
|
||||||
|
while (*str) putwchar(*str++);
|
||||||
|
}
|
||||||
|
|
||||||
Result<void> println(const char* str)
|
Result<void> println(const char* str)
|
||||||
{
|
{
|
||||||
TRY(print(str));
|
TRY(print(str));
|
||||||
@ -179,6 +184,12 @@ namespace TextConsole
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wprintln(const wchar_t* str)
|
||||||
|
{
|
||||||
|
wprint(str);
|
||||||
|
putwchar(L'\n');
|
||||||
|
}
|
||||||
|
|
||||||
Result<usize> printf(const char* format, ...)
|
Result<usize> printf(const char* format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -14,6 +14,8 @@ namespace TextConsole
|
|||||||
u32 background();
|
u32 background();
|
||||||
void move_to(u32 x, u32 y);
|
void move_to(u32 x, u32 y);
|
||||||
Result<void> print(const char* str);
|
Result<void> print(const char* str);
|
||||||
|
void wprint(const wchar_t* str);
|
||||||
Result<void> println(const char* str);
|
Result<void> println(const char* str);
|
||||||
|
void wprintln(const wchar_t* str);
|
||||||
Result<usize> printf(const char* format, ...) _format(1, 2);
|
Result<usize> printf(const char* format, ...) _format(1, 2);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user