From 3fddf0414b67050d3abb81b08b51680c1ba4a261 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 10 Mar 2022 18:08:20 +0000 Subject: [PATCH] A bit of wxT(). --- common/rc_item.cpp | 4 +- common/scintilla_tricks.cpp | 4 +- common/string_utils.cpp | 116 ++++++++++++++++++------------------ common/stroke_params.cpp | 14 ++--- 4 files changed, 69 insertions(+), 69 deletions(-) diff --git a/common/rc_item.cpp b/common/rc_item.cpp index 4c955d48e2..ab585f3901 100644 --- a/common/rc_item.cpp +++ b/common/rc_item.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -46,7 +46,7 @@ wxString RC_ITEM::GetErrorMessage() const wxString RC_ITEM::ShowCoord( EDA_UNITS aUnits, const VECTOR2I& aPos ) { - return wxString::Format( "@(%s, %s)", + return wxString::Format( wxT( "@(%s, %s)" ), MessageTextFromValue( aUnits, aPos.x ), MessageTextFromValue( aUnits, aPos.y ) ); } diff --git a/common/scintilla_tricks.cpp b/common/scintilla_tricks.cpp index 9f8f54f78f..3e5bb76559 100644 --- a/common/scintilla_tricks.cpp +++ b/common/scintilla_tricks.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2020-2022 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -268,7 +268,7 @@ void SCINTILLA_TRICKS::onCharHook( wxKeyEvent& aEvent ) for( int ii = startLine; ii <= endLine; ++ii ) { if( comment ) - m_te->InsertText( m_te->PositionFromLine( ii ), "#" ); + m_te->InsertText( m_te->PositionFromLine( ii ), wxT( "#" ) ); else if( firstNonWhitespace( ii, &whitespaceCount ) == '#' ) m_te->DeleteRange( m_te->PositionFromLine( ii ) + whitespaceCount, 1 ); } diff --git a/common/string_utils.cpp b/common/string_utils.cpp index 6fdcc344f1..28351580f7 100644 --- a/common/string_utils.cpp +++ b/common/string_utils.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -47,7 +47,7 @@ wxString ConvertToNewOverbarNotation( const wxString& aOldStr ) bool inOverbar = false; // Don't get tripped up by the legacy empty-string token. - if( aOldStr == "~" ) + if( aOldStr == wxT( "~" ) ) return aOldStr; newStr.reserve( aOldStr.length() ); @@ -64,12 +64,12 @@ wxString ConvertToNewOverbarNotation( const wxString& aOldStr ) { // This way the subsequent opening curly brace will not start an // overbar. - newStr << "~~{}"; + newStr << wxT( "~~{}" ); continue; } // Two subsequent tildes mean a tilde. - newStr << "~"; + newStr << wxT( "~" ); ++chIt; continue; } @@ -83,12 +83,12 @@ wxString ConvertToNewOverbarNotation( const wxString& aOldStr ) { if( inOverbar ) { - newStr << "}"; + newStr << wxT( "}" ); inOverbar = false; } else { - newStr << "~{"; + newStr << wxT( "~{" ); inOverbar = true; } @@ -98,7 +98,7 @@ wxString ConvertToNewOverbarNotation( const wxString& aOldStr ) else if( ( *chIt == ' ' || *chIt == '}' || *chIt == ')' ) && inOverbar ) { // Spaces were used to terminate overbar as well - newStr << "}"; + newStr << wxT( "}" ); inOverbar = false; } @@ -107,7 +107,7 @@ wxString ConvertToNewOverbarNotation( const wxString& aOldStr ) // Explicitly end the overbar even if there was no terminating '~' in the aOldStr. if( inOverbar ) - newStr << "}"; + newStr << wxT( "}" ); return newStr; } @@ -159,89 +159,89 @@ wxString EscapeString( const wxString& aSource, ESCAPE_CONTEXT aContext ) if( aContext == CTX_NETNAME ) { if( c == '/' ) - converted += "{slash}"; + converted += wxT( "{slash}" ); else if( c == '\n' || c == '\r' ) - converted += ""; // drop + converted += wxEmptyString; // drop else converted += c; } else if( aContext == CTX_LIBID ) { if( c == '{' && !hasFormattingPrefix() ) - converted += "{brace}"; + converted += wxT( "{brace}" ); else if( c == '/' ) - converted += "{slash}"; + converted += wxT( "{slash}" ); else if( c == '\\' ) - converted += "{backslash}"; + converted += wxT( "{backslash}" ); else if( c == '<' ) - converted += "{lt}"; + converted += wxT( "{lt}" ); else if( c == '>' ) - converted += "{gt}"; + converted += wxT( "{gt}" ); else if( c == ':' ) - converted += "{colon}"; + converted += wxT( "{colon}" ); else if( c == '\"' ) - converted += "{dblquote}"; + converted += wxT( "{dblquote}" ); else if( c == '\n' || c == '\r' ) - converted += ""; // drop + converted += wxEmptyString; // drop else converted += c; } else if( aContext == CTX_IPC ) { if( c == '/' ) - converted += "{slash}"; + converted += wxT( "{slash}" ); else if( c == ',' ) - converted += "{comma}"; + converted += wxT( "{comma}" ); else if( c == '\"' ) - converted += "{dblquote}"; + converted += wxT( "{dblquote}" ); else converted += c; } else if( aContext == CTX_QUOTED_STR ) { if( c == '\"' ) - converted += "{dblquote}"; + converted += wxT( "{dblquote}" ); else converted += c; } else if( aContext == CTX_LINE ) { if( c == '\n' || c == '\r' ) - converted += "{return}"; + converted += wxT( "{return}" ); else converted += c; } else if( aContext == CTX_FILENAME ) { if( c == '{' ) - converted += "{brace}"; + converted += wxT( "{brace}" ); else if( c == '/' ) - converted += "{slash}"; + converted += wxT( "{slash}" ); else if( c == '\\' ) - converted += "{backslash}"; + converted += wxT( "{backslash}" ); else if( c == '\"' ) - converted += "{dblquote}"; + converted += wxT( "{dblquote}" ); else if( c == '<' ) - converted += "{lt}"; + converted += wxT( "{lt}" ); else if( c == '>' ) - converted += "{gt}"; + converted += wxT( "{gt}" ); else if( c == '|' ) - converted += "{bar}"; + converted += wxT( "{bar}" ); else if( c == ':' ) - converted += "{colon}"; + converted += wxT( "{colon}" ); else if( c == '\t' ) - converted += "{tab}"; + converted += wxT( "{tab}" ); else if( c == '\n' || c == '\r' ) - converted += "{return}"; + converted += wxT( "{return}" ); else converted += c; } else if( aContext == CTX_NO_SPACE ) { if( c == ' ' ) - converted += "{space}"; + converted += wxT( "{space}" ); else if( c == '{' ) - converted += "{brace}"; + converted += wxT( "{brace}" ); else converted += c; } @@ -302,24 +302,24 @@ wxString UnescapeString( const wxString& aSource ) token.append( ch ); } - if( token == wxS( "dblquote" ) ) newbuf.append( wxS( "\"" ) ); - else if( token == wxS( "quote" ) ) newbuf.append( wxS( "'" ) ); - else if( token == wxS( "lt" ) ) newbuf.append( wxS( "<" ) ); - else if( token == wxS( "gt" ) ) newbuf.append( wxS( ">" ) ); - else if( token == wxS( "backslash" ) ) newbuf.append( wxS( "\\" ) ); - else if( token == wxS( "slash" ) ) newbuf.append( wxS( "/" ) ); - else if( token == wxS( "bar" ) ) newbuf.append( wxS( "|" ) ); - else if( token == wxS( "comma" ) ) newbuf.append( wxS( "," ) ); - else if( token == wxS( "colon" ) ) newbuf.append( wxS( ":" ) ); - else if( token == wxS( "space" ) ) newbuf.append( wxS( " " ) ); - else if( token == wxS( "dollar" ) ) newbuf.append( wxS( "$" ) ); - else if( token == wxS( "tab" ) ) newbuf.append( wxS( "\t" ) ); - else if( token == wxS( "return" ) ) newbuf.append( wxS( "\n" ) ); - else if( token == wxS( "brace" ) ) newbuf.append( wxS( "{" ) ); - else if( token.IsEmpty() ) newbuf.append( wxS( "{" ) ); + if( token == wxT( "dblquote" ) ) newbuf.append( wxT( "\"" ) ); + else if( token == wxT( "quote" ) ) newbuf.append( wxT( "'" ) ); + else if( token == wxT( "lt" ) ) newbuf.append( wxT( "<" ) ); + else if( token == wxT( "gt" ) ) newbuf.append( wxT( ">" ) ); + else if( token == wxT( "backslash" ) ) newbuf.append( wxT( "\\" ) ); + else if( token == wxT( "slash" ) ) newbuf.append( wxT( "/" ) ); + else if( token == wxT( "bar" ) ) newbuf.append( wxT( "|" ) ); + else if( token == wxT( "comma" ) ) newbuf.append( wxT( "," ) ); + else if( token == wxT( "colon" ) ) newbuf.append( wxT( ":" ) ); + else if( token == wxT( "space" ) ) newbuf.append( wxT( " " ) ); + else if( token == wxT( "dollar" ) ) newbuf.append( wxT( "$" ) ); + else if( token == wxT( "tab" ) ) newbuf.append( wxT( "\t" ) ); + else if( token == wxT( "return" ) ) newbuf.append( wxT( "\n" ) ); + else if( token == wxT( "brace" ) ) newbuf.append( wxT( "{" ) ); + else if( token.IsEmpty() ) newbuf.append( wxT( "{" ) ); else { - newbuf.append( "{" + UnescapeString( token ) + "}" ); + newbuf.append( wxT( "{" ) + UnescapeString( token ) + wxT( "}" ) ); } } else @@ -452,8 +452,8 @@ std::string EscapedUTF8( const wxString& aString ) wxString str = aString; // No new-lines allowed in quoted strings - str.Replace( "\r\n", "\r" ); - str.Replace( "\n", "\r" ); + str.Replace( wxT( "\r\n" ), wxT( "\r" ) ); + str.Replace( wxT( "\n" ), wxT( "\r" ) ); std::string utf8 = TO_UTF8( aString ); @@ -497,15 +497,15 @@ wxString EscapeHTML( const wxString& aString ) for( wxUniChar c : aString ) { if( c == '\"' ) - converted += """; + converted += wxT( """ ); else if( c == '\'' ) - converted += "'"; + converted += wxT( "'" ); else if( c == '&' ) - converted += "&"; + converted += wxT( "&" ); else if( c == '<' ) - converted += "<"; + converted += wxT( "<" ); else if( c == '>' ) - converted += ">"; + converted += wxT( ">" ); else converted += c; } diff --git a/common/stroke_params.cpp b/common/stroke_params.cpp index d57b265c2a..ac60e8c147 100644 --- a/common/stroke_params.cpp +++ b/common/stroke_params.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -179,12 +179,12 @@ static wxString getLineStyleToken( PLOT_DASH_TYPE aStyle ) switch( aStyle ) { - case PLOT_DASH_TYPE::DASH: token = "dash"; break; - case PLOT_DASH_TYPE::DOT: token = "dot"; break; - case PLOT_DASH_TYPE::DASHDOT: token = "dash_dot"; break; - case PLOT_DASH_TYPE::DASHDOTDOT: token = "dash_dot_dot"; break; - case PLOT_DASH_TYPE::SOLID: token = "solid"; break; - case PLOT_DASH_TYPE::DEFAULT: token = "default"; break; + case PLOT_DASH_TYPE::DASH: token = wxT( "dash" ); break; + case PLOT_DASH_TYPE::DOT: token = wxT( "dot" ); break; + case PLOT_DASH_TYPE::DASHDOT: token = wxT( "dash_dot" ); break; + case PLOT_DASH_TYPE::DASHDOTDOT: token = wxT( "dash_dot_dot" ); break; + case PLOT_DASH_TYPE::SOLID: token = wxT( "solid" ); break; + case PLOT_DASH_TYPE::DEFAULT: token = wxT( "default" ); break; } return token;