Remove unnecessary locale/UTF-8 encoding conversions

This commit is contained in:
Jānis Rūcis 2010-05-20 19:13:48 +03:00
parent f1193766e1
commit b566370748
9 changed files with 20 additions and 38 deletions

View File

@ -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);

View File

@ -138,7 +138,7 @@ class XMLSAXImporter
static void characters(void *user_data, const xmlChar *ch, int len)
{
reinterpret_cast<XMLSAXImporter*>(user_data)->m_importer
<< ConvertUTF8ToLocale(StringRange(reinterpret_cast<const char*>(ch), reinterpret_cast<const char*>(ch + len)));
<< StringRange(reinterpret_cast<const char*>(ch), reinterpret_cast<const char*>(ch + len));
}
static void warning(void *user_data, const char *msg, ...)

View File

@ -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)
{

View File

@ -216,7 +216,7 @@ std::size_t Sys_Print(int level, const char* buf, std::size_t length)
if(!globalCharacterSet().isUTF8())
{
BufferedTextOutputStream<GtkTextBufferOutputStream> buffered(textBuffer);
buffered << ConvertLocaleToUTF8(StringRange(buf, buf + length));
buffered << StringRange(buf, buf + length);
}
else
{

View File

@ -170,31 +170,13 @@ void IntRadioExport(GtkRadioButton& widget, const IntImportCallback& importCallb
}
typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
template<typename Type, typename Formatter>
class StringFromType
{
StringOutputStream value;
public:
StringFromType(const Type& type)
{
value << Formatter(type);
}
operator const char*() const
{
return value.c_str();
}
};
typedef StringFromType<const char*, ConvertLocaleToUTF8> LocaleToUTF8;
typedef StringFromType<const char*, ConvertUTF8ToLocale> 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<GtkEntry, const char*, TextEntryImport, TextEntryExport> TextEntryImportExport;

View File

@ -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<StringAttribute, &StringAttribute::apply> 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<StringAttribute, &StringAttribute::update> 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<ModelAttribute, &ModelAttribute::apply> 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<ModelAttribute, &ModelAttribute::update> 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<SoundAttribute, &SoundAttribute::apply> 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<SoundAttribute, &SoundAttribute::update> 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)
{

View File

@ -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());
}

View File

@ -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)
{

View File

@ -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<const char*>(ch), reinterpret_cast<const char*>(ch + len)));
ostream << StringRange(reinterpret_cast<const char*>(ch), reinterpret_cast<const char*>(ch + len));
}
static void saxComment(void *ctx, const xmlChar *msg)