From b56637074830f2a4df0ce319033b9089bc900add Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C4=81nis=20R=C5=ABcis?= Date: Thu, 20 May 2010 19:13:48 +0300 Subject: [PATCH] Remove unnecessary locale/UTF-8 encoding conversions --- contrib/prtview/LoadPortalFileDialog.cpp | 2 +- libs/xml/xmlparser.h | 2 +- libs/xml/xmlwriter.h | 2 +- radiant/console.cpp | 2 +- radiant/dialog.cpp | 22 ++-------------------- radiant/entityinspector.cpp | 22 +++++++++++----------- radiant/mru.cpp | 2 +- radiant/qe3.cpp | 2 +- radiant/watchbsp.cpp | 2 +- 9 files changed, 20 insertions(+), 38 deletions(-) diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index d9984a0..03d8439 100644 --- a/contrib/prtview/LoadPortalFileDialog.cpp +++ b/contrib/prtview/LoadPortalFileDialog.cpp @@ -176,7 +176,7 @@ int DoLoadPortalFileDialog () } StringOutputStream value(256); - value << ConvertLocaleToUTF8(portals.fn); + value << portals.fn; gtk_entry_set_text (GTK_ENTRY (entry), value.c_str()); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check2d), portals.show_2d); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check3d), portals.show_3d); diff --git a/libs/xml/xmlparser.h b/libs/xml/xmlparser.h index 0b70c2f..8fef04f 100644 --- a/libs/xml/xmlparser.h +++ b/libs/xml/xmlparser.h @@ -138,7 +138,7 @@ class XMLSAXImporter static void characters(void *user_data, const xmlChar *ch, int len) { reinterpret_cast(user_data)->m_importer - << ConvertUTF8ToLocale(StringRange(reinterpret_cast(ch), reinterpret_cast(ch + len))); + << StringRange(reinterpret_cast(ch), reinterpret_cast(ch + len)); } static void warning(void *user_data, const char *msg, ...) diff --git a/libs/xml/xmlwriter.h b/libs/xml/xmlwriter.h index 85e49d4..ec5a4ad 100644 --- a/libs/xml/xmlwriter.h +++ b/libs/xml/xmlwriter.h @@ -113,7 +113,7 @@ class XMLStreamWriter : public XMLImporter, public XMLAttrVisitor void write_cdata(const char* buffer, std::size_t length) { - m_ostream << ConvertLocaleToUTF8(StringRange(buffer, buffer + length)); + m_ostream << StringRange(buffer, buffer + length); } void write_string(const char* string) { diff --git a/radiant/console.cpp b/radiant/console.cpp index 94a496f..db7997e 100644 --- a/radiant/console.cpp +++ b/radiant/console.cpp @@ -216,7 +216,7 @@ std::size_t Sys_Print(int level, const char* buf, std::size_t length) if(!globalCharacterSet().isUTF8()) { BufferedTextOutputStream buffered(textBuffer); - buffered << ConvertLocaleToUTF8(StringRange(buf, buf + length)); + buffered << StringRange(buf, buf + length); } else { diff --git a/radiant/dialog.cpp b/radiant/dialog.cpp index 3f24bf8..d3e4dba 100644 --- a/radiant/dialog.cpp +++ b/radiant/dialog.cpp @@ -170,31 +170,13 @@ void IntRadioExport(GtkRadioButton& widget, const IntImportCallback& importCallb } typedef ImportExport IntRadioImportExport; -template -class StringFromType -{ - StringOutputStream value; -public: - StringFromType(const Type& type) - { - value << Formatter(type); - } - operator const char*() const - { - return value.c_str(); - } -}; - -typedef StringFromType LocaleToUTF8; -typedef StringFromType UTF8ToLocale; - void TextEntryImport(GtkEntry& widget, const char* text) { - gtk_entry_set_text(&widget, LocaleToUTF8(text)); + gtk_entry_set_text(&widget, text); } void TextEntryExport(GtkEntry& widget, const StringImportCallback& importCallback) { - importCallback(UTF8ToLocale(gtk_entry_get_text(&widget))); + importCallback(gtk_entry_get_text(&widget)); } typedef ImportExport TextEntryImportExport; diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index e2f3c19..ab9cabd 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -216,7 +216,7 @@ public: void apply() { StringOutputStream value(64); - value << ConvertUTF8ToLocale(gtk_entry_get_text(m_entry)); + value << gtk_entry_get_text(m_entry); Scene_EntitySetKeyValue_Selected_Undoable(m_key.c_str(), value.c_str()); } typedef MemberCaller ApplyCaller; @@ -224,7 +224,7 @@ public: void update() { StringOutputStream value(64); - value << ConvertLocaleToUTF8(SelectedEntity_getValueForKey(m_key.c_str())); + value << SelectedEntity_getValueForKey(m_key.c_str()); gtk_entry_set_text(m_entry, value.c_str()); } typedef MemberCaller UpdateCaller; @@ -264,14 +264,14 @@ public: void apply() { StringOutputStream value(64); - value << ConvertUTF8ToLocale(gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry))); + value << gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry)); Scene_EntitySetKeyValue_Selected_Undoable(m_key.c_str(), value.c_str()); } typedef MemberCaller ApplyCaller; void update() { StringOutputStream value(64); - value << ConvertLocaleToUTF8(SelectedEntity_getValueForKey(m_key.c_str())); + value << SelectedEntity_getValueForKey(m_key.c_str()); gtk_entry_set_text(GTK_ENTRY(m_entry.m_entry.m_entry), value.c_str()); } typedef MemberCaller UpdateCaller; @@ -338,14 +338,14 @@ public: void apply() { StringOutputStream value(64); - value << ConvertUTF8ToLocale(gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry))); + value << gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry)); Scene_EntitySetKeyValue_Selected_Undoable(m_key.c_str(), value.c_str()); } typedef MemberCaller ApplyCaller; void update() { StringOutputStream value(64); - value << ConvertLocaleToUTF8(SelectedEntity_getValueForKey(m_key.c_str())); + value << SelectedEntity_getValueForKey(m_key.c_str()); gtk_entry_set_text(GTK_ENTRY(m_entry.m_entry.m_entry), value.c_str()); } typedef MemberCaller UpdateCaller; @@ -1170,9 +1170,9 @@ void EntityInspector_updateKeyValues() GtkTreeIter iter; gtk_list_store_append(store, &iter); StringOutputStream key(64); - key << ConvertLocaleToUTF8((*i).first.c_str()); + key << (*i).first.c_str(); StringOutputStream value(64); - value << ConvertLocaleToUTF8((*i).second.c_str()); + value << (*i).second.c_str(); gtk_list_store_set(store, &iter, 0, key.c_str(), 1, value.c_str(), -1); } @@ -1243,9 +1243,9 @@ void EntityInspector_applyKeyValue() { // Get current selection text StringOutputStream key(64); - key << ConvertUTF8ToLocale(gtk_entry_get_text(g_entityKeyEntry)); + key << gtk_entry_get_text(g_entityKeyEntry); StringOutputStream value(64); - value << ConvertUTF8ToLocale(gtk_entry_get_text(g_entityValueEntry)); + value << gtk_entry_get_text(g_entityValueEntry); // TTimo: if you change the classname to worldspawn you won't merge back in the structural brushes but create a parasite entity @@ -1280,7 +1280,7 @@ void EntityInspector_clearKeyValue() { // Get current selection text StringOutputStream key(64); - key << ConvertUTF8ToLocale(gtk_entry_get_text(g_entityKeyEntry)); + key << gtk_entry_get_text(g_entityKeyEntry); if(strcmp(key.c_str(), "classname") != 0) { diff --git a/radiant/mru.cpp b/radiant/mru.cpp index 7f3fbee..2dd0da7 100644 --- a/radiant/mru.cpp +++ b/radiant/mru.cpp @@ -90,7 +90,7 @@ inline EscapedMnemonic& operator<<(EscapedMnemonic& ostream, const T& t) void MRU_updateWidget(std::size_t index, const char *filename) { EscapedMnemonic mnemonic(64); - mnemonic << Unsigned(index + 1) << "- " << ConvertLocaleToUTF8(filename); + mnemonic << Unsigned(index + 1) << "- " << filename; gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(MRU_items[index]))), mnemonic.c_str()); } diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 451489b..0291d2c 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -346,7 +346,7 @@ void RunBSP(const char* name) void Sys_SetTitle(const char *text, bool modified) { StringOutputStream title; - title << ConvertLocaleToUTF8(text); + title << text; if(modified) { diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index e2cc86c..83fba90 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -431,7 +431,7 @@ inline MessageOutputStream& operator<<(MessageOutputStream& ostream, const T& t) static void saxCharacters(message_info_t *data, const xmlChar *ch, int len) { MessageOutputStream ostream(data); - ostream << ConvertUTF8ToLocale(StringRange(reinterpret_cast(ch), reinterpret_cast(ch + len))); + ostream << StringRange(reinterpret_cast(ch), reinterpret_cast(ch + len)); } static void saxComment(void *ctx, const xmlChar *msg) -- 2.39.2