From 73610be10dcb4cf7ad41f25106b5985c310c50ed Mon Sep 17 00:00:00 2001 From: Nimetu Date: Tue, 3 Nov 2020 22:28:01 +0200 Subject: [PATCH] utf-8 fixes, ryzom/ryzomcore#335 --- ryzom/client/src/game_context_menu.cpp | 10 +++---- .../src/interface_v3/chat_text_manager.cpp | 12 ++++---- .../interface_v3/group_in_scene_bubble.cpp | 8 +++--- .../src/interface_v3/interface_manager.cpp | 2 +- .../src/interface_v3/people_interraction.cpp | 4 +-- ryzom/client/src/interface_v3/people_list.cpp | 28 +++++++++---------- ryzom/client/src/interface_v3/people_list.h | 4 +-- ryzom/client/src/net_manager.cpp | 2 +- 8 files changed, 35 insertions(+), 35 deletions(-) diff --git a/ryzom/client/src/game_context_menu.cpp b/ryzom/client/src/game_context_menu.cpp index 17078677d..96b0852c0 100644 --- a/ryzom/client/src/game_context_menu.cpp +++ b/ryzom/client/src/game_context_menu.cpp @@ -768,11 +768,11 @@ void CGameContextMenu::updateContextMenuMissionsOptions( bool forceHide ) { result = NLMISC::CI18N::get("uiMissionOptionNotReceived"); } - if (result == ucstring("Qui etes-vous ?") - || result == ucstring("Wer bist Du?") - || result == ucstring("Who are you?") - || result == ucstring("Quién eres tú?") - || result == ucstring("Кто ты?")) + if (result == string("Qui etes-vous ?") + || result == string("Wer bist Du?") + || result == string("Who are you?") + || result == string("Quién eres tú?") + || result == string("Кто ты?")) { pVTM->setActive(false); } diff --git a/ryzom/client/src/interface_v3/chat_text_manager.cpp b/ryzom/client/src/interface_v3/chat_text_manager.cpp index 35ce74564..96daa2a07 100644 --- a/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -421,14 +421,14 @@ CViewBase *CChatTextManager::createMsgTextComplex(const string &msg, NLMISC::CRG return para; } - ucstring::size_type pos = 0; + string::size_type pos = 0; // Manage Translations CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TRANSLATION_ONLY_AS_TOOLTIP_CB", false); bool originalFirst = node->getValueBool(); - string::size_type startTr = msg.find(ucstring("{:")); - string::size_type endOfOriginal = msg.find(ucstring("}@{")); + string::size_type startTr = msg.find("{:"); + string::size_type endOfOriginal = msg.find("}@{"); // Original/Translated case, example: {:enHello the world!}@{ Bonjour le monde ! if (startTr != string::npos && endOfOriginal != string::npos) @@ -436,9 +436,9 @@ CViewBase *CChatTextManager::createMsgTextComplex(const string &msg, NLMISC::CRG CViewBase *vt = createMsgTextSimple(msg.substr(0, startTr), col, justified, NULL); para->addChild(vt); - string texture = "flag-"+toLower(msg.substr(startTr+2, 2)).toString()+".tga"; - ucstring original = msg.substr(startTr+5, endOfOriginal-startTr-5); - ucstring translation = msg.substr(endOfOriginal+3); + string texture = "flag-"+toLowerAscii(msg.substr(startTr+2, 2))+".tga"; + string original = msg.substr(startTr+5, endOfOriginal-startTr-5); + string translation = msg.substr(endOfOriginal+3); CCtrlButton *ctrlButton = new CCtrlButton(CViewBase::TCtorParam()); ctrlButton->setTexture(texture); ctrlButton->setTextureOver(texture); diff --git a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 60243062c..95bbc1600 100644 --- a/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -849,10 +849,10 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const std::string &ucsTe CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TRANSLATION_ONLY_AS_TOOLTIP_CB", false); bool originalFirst = node->getValueBool(); - ucstring::size_type pos = 0; - ucstring::size_type textSize = ucsText.size(); - string::size_type startTr = ucsText.find(ucstring("{:")); - string::size_type endOfOriginal = ucsText.find(ucstring("}@{")); + string::size_type pos = 0; + string::size_type textSize = ucsText.size(); + string::size_type startTr = ucsText.find("{:"); + string::size_type endOfOriginal = ucsText.find("}@{"); if (endOfOriginal != string::npos) { if (!originalFirst) diff --git a/ryzom/client/src/interface_v3/interface_manager.cpp b/ryzom/client/src/interface_v3/interface_manager.cpp index 8c874d6a5..d6eb63a02 100644 --- a/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/ryzom/client/src/interface_v3/interface_manager.cpp @@ -2535,7 +2535,7 @@ void CInterfaceManager::displaySystemInfo(const string &str, const string &cat) // If broadcast, parse lua code if (toLower(cat) == "bc" && str.size() > 3 && str[0]=='@' && str[1]=='L' && str[2]=='U' && str[3]=='A') { - string code = str.substr(4, str.size()-4).toString(); + string code = str.substr(4, str.size()-4); if (!code.empty()) CLuaManager::getInstance().executeLuaScript(code); return; diff --git a/ryzom/client/src/interface_v3/people_interraction.cpp b/ryzom/client/src/interface_v3/people_interraction.cpp index fc3cc34d8..a2973570c 100644 --- a/ryzom/client/src/interface_v3/people_interraction.cpp +++ b/ryzom/client/src/interface_v3/people_interraction.cpp @@ -2334,7 +2334,7 @@ public: if (gc) { CGroupEditBox *geb = dynamic_cast(gc->getGroup("change_contact_group_eb:eb")); - geb->setInputString(ucstring("")); + geb->setInputString(std::string("")); } CAHManager::getInstance()->runActionHandler("enter_modal", pCaller, sParams); } @@ -2359,7 +2359,7 @@ public: { PeopleInterraction.FriendList.changeGroup(lastPeopleIndexChangeGroup, geb->getInputString()); - geb->setInputString(ucstring("")); + geb->setInputString(std::string("")); CPeopleList::TSortOrder order = (CPeopleList::TSortOrder)(NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CONTACT_LIST:SORT_ORDER")->getValue32()); PeopleInterraction.FriendList.sortEx(order); } diff --git a/ryzom/client/src/interface_v3/people_list.cpp b/ryzom/client/src/interface_v3/people_list.cpp index 292e73ff7..ff3be9f8c 100644 --- a/ryzom/client/src/interface_v3/people_list.cpp +++ b/ryzom/client/src/interface_v3/people_list.cpp @@ -287,7 +287,7 @@ void CPeopleList::sortEx(TSortOrder order) { newGroup = true; } - while (groupIndex < _GroupContainers.size() && _GroupContainers[groupIndex].first != _Peoples[k].Group.toString()) + while (groupIndex < _GroupContainers.size() && _GroupContainers[groupIndex].first != _Peoples[k].Group) { newGroup = true; ++groupIndex; @@ -479,44 +479,44 @@ void CPeopleList::setContactId(uint index, uint32 contactId) } //================================================================== -void CPeopleList::changeGroup(uint index, const ucstring &groupName) +void CPeopleList::changeGroup(uint index, const std::string &groupName) { if (index >= _Peoples.size()) { nlwarning(" bad index."); return; } - ucstring group = groupName; - if (group.toString() == "General") - group = ucstring(""); + std::string group = groupName; + if (group == "General") + group.clear(); _Peoples[index].Group = group; for (uint k = 0; k < _GroupContainers.size(); ++k) { - if (_GroupContainers[k].first == group.toString()) + if (_GroupContainers[k].first == group) return; } vector > properties; properties.push_back(make_pair(string("posparent"), string("parent"))); properties.push_back(make_pair(string("id"), _ContainerID + "_group_" + toString(_GroupContainers.size()))); - if (group.toString() == "") + if (group.empty()) properties.push_back(make_pair(string("title"), "General")); else - properties.push_back(make_pair(string("title"), group.toString())); + properties.push_back(make_pair(string("title"), group)); CGroupContainer *gc = dynamic_cast(CWidgetManager::getInstance()->getParser()->createGroupInstance("people_list_group_header", "ui:interface", properties, false)); - if (group.toString() == "") - gc->setUCTitle(ucstring("General")); + if (group.empty()) + gc->setTitle(std::string("General")); else - gc->setUCTitle(group.toString()); + gc->setTitle(group); gc->setSavable(false); CInterfaceGroup *pRoot = dynamic_cast(CWidgetManager::getInstance()->getElementFromId("ui:interface")); pRoot->addGroup (gc); _BaseContainer->attachContainer(gc); - _GroupContainers.push_back(make_pair(group.toString(), gc)); + _GroupContainers.push_back(make_pair(group, gc)); std::sort(_GroupContainers.begin(), _GroupContainers.end()); } @@ -627,8 +627,8 @@ void CPeopleList::saveContactGroups() { xmlNodePtr newNode = xmlNewChild(node, NULL, (const xmlChar*)"contact", NULL); - xmlSetProp(newNode, (const xmlChar*)"name", (const xmlChar*)_Peoples[k].getName().toString().c_str()); - xmlSetProp(newNode, (const xmlChar*)"group", (const xmlChar*)_Peoples[k].Group.toString().c_str()); + xmlSetProp(newNode, (const xmlChar*)"name", (const xmlChar*)_Peoples[k].getName().c_str()); + xmlSetProp(newNode, (const xmlChar*)"group", (const xmlChar*)_Peoples[k].Group.c_str()); } stream.flush(); fd.close(); diff --git a/ryzom/client/src/interface_v3/people_list.h b/ryzom/client/src/interface_v3/people_list.h index 060fa039c..79a575a95 100644 --- a/ryzom/client/src/interface_v3/people_list.h +++ b/ryzom/client/src/interface_v3/people_list.h @@ -110,7 +110,7 @@ public: sint getIndexFromContactId(uint32 contactId); // For Friend Groups management - void changeGroup(uint index, const ucstring &groupName); + void changeGroup(uint index, const std::string &groupName); void readContactGroups(); void saveContactGroups(); @@ -162,7 +162,7 @@ private: TCharConnectionState Online; bool Blocked; uint32 ContactId; - ucstring Group; + std::string Group; bool operator < (const CPeople &other) const { return getName() < other.getName(); } std::string getName() const { return Container->getTitle(); } }; diff --git a/ryzom/client/src/net_manager.cpp b/ryzom/client/src/net_manager.cpp index 18ffd867c..3dfc07818 100644 --- a/ryzom/client/src/net_manager.cpp +++ b/ryzom/client/src/net_manager.cpp @@ -147,7 +147,7 @@ extern bool CharNameValidArrived; extern bool CharNameValid; bool IsInRingSession = false; TSessionId HighestMainlandSessionId; // highest in the position stack -ucstring lastUniversMessage; +std::string lastUniversMessage; extern const char *CDBBankNames[INVALID_CDB_BANK+1];