From: Jānis Rūcis Date: Thu, 20 May 2010 16:13:48 +0000 (+0300) Subject: Remove unnecessary locale/UTF-8 encoding conversions X-Git-Tag: xonotic-v0.5.0~260 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=commitdiff_plain;h=b56637074830f2a4df0ce319033b9089bc900add;ds=sidebyside Remove unnecessary locale/UTF-8 encoding conversions --- diff --git a/contrib/prtview/LoadPortalFileDialog.cpp b/contrib/prtview/LoadPortalFileDialog.cpp index d9984a0b..03d84397 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 0b70c2f4..8fef04f5 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 85e49d45..ec5a4ade 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 94a496f6..db7997e1 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 3f24bf84..d3e4dba1 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 e2f3c194..ab9cabd7 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 7f3fbeeb..2dd0da72 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 451489b5..0291d2cf 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 e2cc86c3..83fba900 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)