From be91c4da700639b34f79192969a6afb86e5bee80 Mon Sep 17 00:00:00 2001 From: docentYT <63965954+docentYT@users.noreply.github.com> Date: Tue, 12 May 2026 16:36:32 +0200 Subject: [PATCH] Fix C4566 --- application/driveruipanels.cpp | 21 +++++++++++---------- utilities/U8.h | 3 +++ utilities/utilities.cpp | 4 +++- 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 utilities/U8.h diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 52eb3fd3..f316f175 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -29,6 +29,7 @@ http://mozilla.org/MPL/2.0/. #include "rendering/renderer.h" #include "utilities/Logs.h" #include "widgets/vehicleparams.h" +#include "utilities/U8.h" #define DRIVER_HINT_CONTENT #include "application/driverhints.h" @@ -390,7 +391,7 @@ timetable_panel::update() { } else { // header - m_tablelines.emplace_back( "┌─────┬────────────────────────────────────┬─────────┬─────┐", Global.UITextColor ); + m_tablelines.emplace_back(U8("┌─────┬────────────────────────────────────┬─────────┬─────┐"), Global.UITextColor); TMTableLine const *tableline; for( int i = table.StationStart; i <= table.StationCount; ++i ) { @@ -422,11 +423,11 @@ timetable_panel::update() { auto const arrival { ( tableline->Ah >= 0 ? std::to_string( int( 100 + tableline->Ah ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Am, true, 3 ) : - " │ " ) }; + U8(" │ ") ) }; auto const departure { ( tableline->Dh >= 0 ? std::to_string( int( 100 + tableline->Dh ) ).substr( 1, 2 ) + ":" + to_minutes_str( tableline->Dm, true, 3 ) : - " │ " ) }; + U8(" │ ") ) }; auto const candepart { ( ( table.StationStart < table.StationIndex ) && ( i < table.StationIndex ) @@ -445,25 +446,25 @@ timetable_panel::update() { candepart ? colors::uitextgreen : // czas minął i odjazd był, to nazwa stacji będzie na zielono isatpassengerstop ? colors::uitextorange : Global.UITextColor ) }; - auto const trackcount{ ( tableline->TrackNo == 1 ? " ┃ " : " ║ " ) }; + std::string const trackcount{ ( tableline->TrackNo == 1 ? U8(" ┃ ") : U8(" ║ " )) }; m_tablelines.emplace_back( - ( "│ " + vmax + " │ " + station + trackcount + arrival + " │ " + traveltime + " │" ), + ( U8("│ ") + vmax + U8(" │ ") + station + trackcount + arrival + U8(" │ ") + traveltime + U8(" │") ), linecolor ); m_tablelines.emplace_back( - ( "│ │ " + location + tableline->StationWare + trackcount + departure + " │ │" ), + ( U8("│ │ ") + location + tableline->StationWare + trackcount + departure + U8(" │ │") ), linecolor ); // divider/footer if( i < table.StationCount ) { auto const *nexttableline { tableline + 1 }; - std::string const vmaxnext{ ( tableline->vmax == nexttableline->vmax ? "│ ├" : "├─────┼" ) }; - auto const trackcountnext{ ( nexttableline->TrackNo == 1 ? "╂" : "╫" ) }; + std::string const vmaxnext{ ( tableline->vmax == nexttableline->vmax ? U8("│ ├") : U8("├─────┼") ) }; + auto const trackcountnext{ ( nexttableline->TrackNo == 1 ? U8("╂") : U8("╫") ) }; m_tablelines.emplace_back( - vmaxnext + "────────────────────────────────────" + trackcountnext + "─────────┼─────┤", + vmaxnext + U8("────────────────────────────────────") + trackcountnext + U8("─────────┼─────┤"), Global.UITextColor ); } else { m_tablelines.emplace_back( - "└─────┴────────────────────────────────────┴─────────┴─────┘", + U8("└─────┴────────────────────────────────────┴─────────┴─────┘"), Global.UITextColor ); } } diff --git a/utilities/U8.h b/utilities/U8.h new file mode 100644 index 00000000..a0a94381 --- /dev/null +++ b/utilities/U8.h @@ -0,0 +1,3 @@ +#pragma once + +#define U8(str) (const char *)u8##str \ No newline at end of file diff --git a/utilities/utilities.cpp b/utilities/utilities.cpp index 4d915940..c0b18ed5 100644 --- a/utilities/utilities.cpp +++ b/utilities/utilities.cpp @@ -27,6 +27,8 @@ Copyright (C) 2007-2014 Maciej Cierniak #include "utilities/utilities.h" #include "utilities/Globals.h" #include "utilities/parser.h" +#include "utilities/U8.h" + //#include "utilities/Logs.h" @@ -204,7 +206,7 @@ std::string to_hex_str(int const Value, int const Width) return o.str(); }; -std::string const fractionlabels[] = {" ", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"}; +std::string const fractionlabels[] = {U8(" "), U8("¹"), U8("²"), U8("³"), U8("⁴"), U8("⁵"), U8("⁶"), U8("⁷"), U8("⁸"), U8("⁹")}; std::string to_minutes_str(float const Minutes, bool const Leadingzero, int const Width) {