From 466d8e882063e5c8c29f33bc327f7e28267a8f4e Mon Sep 17 00:00:00 2001 From: Henrique Santiago Date: Tue, 7 Aug 2012 21:12:36 -0300 Subject: [PATCH] Use custom upchar and lochar by default due to accents in font files. --- modules/client_locales/locales/pt.lua | 2 +- src/framework/stdext/string.cpp | 16 +++++++++------- src/framework/stdext/string.h | 1 + src/framework/ui/uiwidgettext.cpp | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/client_locales/locales/pt.lua b/modules/client_locales/locales/pt.lua index 3921edd6..d617b54c 100644 --- a/modules/client_locales/locales/pt.lua +++ b/modules/client_locales/locales/pt.lua @@ -131,7 +131,7 @@ locale = { ["Hit Points"] = "Pontos de Vida", ["Hold right mouse button to navigate\nScroll mouse middle button to zoom"] = "Segure o botão direito do mouse para navegar\nRole o botão central do mouse para mudar o zoom", ["Hotkeys"] = "Atalhos", - ["If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character."] = "Se você desligar o programa o seu personagem pode continuar no jogo.\nClique em 'Sair' para assegurar que seu personagem saia do jogo adequadamente.\nClique em 'Forçar Saida' se voce quer fechar o programa sem desconectar seu personagem.", + ["If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character."] = "Se você desligar o programa o seu personagem pode continuar no jogo.\nClique em 'Sair' para assegurar que seu personagem saia do jogo adequadamente.\nClique em 'Forçar Saida' para fechar o programa sem desconectar seu personagem.", ["Ignore capacity"] = "Ignorar capacidade", ["Ignore equipped"] = "Ignorar equipado", ["Interface framerate limit: %s"] = "Limite da taxa de quadros da interface: %s", diff --git a/src/framework/stdext/string.cpp b/src/framework/stdext/string.cpp index 32359f27..232f9ef5 100644 --- a/src/framework/stdext/string.cpp +++ b/src/framework/stdext/string.cpp @@ -101,12 +101,12 @@ std::string utf8_to_latin1(uchar *utf8) void tolower(std::string& str) { - boost::to_lower(str); + std::transform(str.begin(), str.end(), str.begin(), lochar); } void toupper(std::string& str) { - boost::to_upper(str); + std::transform(str.begin(), str.end(), str.begin(), upchar); } void trim(std::string& str) @@ -116,14 +116,16 @@ void trim(std::string& str) char upchar(char c) { -#if defined(__GNUC__) && __GNUC__ >= 3 - return ::toupper(c); // use the one from global scope "ctype.h" -#else - if((c >= 97 && c <= 122) || (c <= -1 && c >= -32)) + if((c >= 97 && c <= 122) || (uchar)c >= 224) c -= 32; + return c; +} +char lochar(char c) +{ + if((c >= 65 && c <= 90) || ((uchar)c >= 192 && (uchar)c <= 223)) + c += 32; return c; -#endif } void ucwords(std::string& str) diff --git a/src/framework/stdext/string.h b/src/framework/stdext/string.h index 1708a18a..3e6fa5fb 100644 --- a/src/framework/stdext/string.h +++ b/src/framework/stdext/string.h @@ -48,6 +48,7 @@ void toupper(std::string& str); void trim(std::string& str); void ucwords(std::string& str); char upchar(char c); +char lochar(char c); bool ends_with(const std::string& str, const std::string& test); bool starts_with(const std::string& str, const std::string& test); void replace_all(std::string& str, const std::string& search, const std::string& replacement); diff --git a/src/framework/ui/uiwidgettext.cpp b/src/framework/ui/uiwidgettext.cpp index 50aa0007..72e0b182 100644 --- a/src/framework/ui/uiwidgettext.cpp +++ b/src/framework/ui/uiwidgettext.cpp @@ -108,7 +108,7 @@ void UIWidget::onFontChange(const std::string& font) void UIWidget::setText(std::string text) { if(m_textOnlyUpperCase) - std::transform(text.begin(), text.end(), text.begin(), toupper); + stdext::toupper(text); if(m_text == text) return;