diff --git a/nel/include/nel/georges/form_elm.h b/nel/include/nel/georges/form_elm.h index bf9b3ef62..6795ad328 100644 --- a/nel/include/nel/georges/form_elm.h +++ b/nel/include/nel/georges/form_elm.h @@ -631,7 +631,7 @@ inline bool CFormElm::convertValue (bool &result, const std::string &value) cons } else { - std::string temp = NLMISC::toLower(value); + std::string temp = NLMISC::toLowerAscii(value); if (strcmp (temp.c_str (), "true") == 0) { result = true; diff --git a/nel/include/nel/misc/common.h b/nel/include/nel/misc/common.h index 1e99b5e70..12ad31ceb 100644 --- a/nel/include/nel/misc/common.h +++ b/nel/include/nel/misc/common.h @@ -267,6 +267,18 @@ void toLowerAscii(char *str, char replacement); std::string toUpperAscii(const std::string &str, char replacement); void toUpperAscii(char *str, char replacement); +/** ASCII to lowercase. Useful for internal identifiers. +* Characters outside of the 7-bit ASCII space are not affected. +*/ +std::string toLowerAscii(const std::string &str); +void toLowerAscii(char *str); + +/** ASCII to uppercase. Useful for internal identifiers. +* Characters outside of the 7-bit ASCII space are not affected. +*/ +std::string toUpperAscii(const std::string &str); +void toUpperAscii(char *str); + /** * Convert to an hexadecimal std::string */ diff --git a/nel/include/nel/misc/utf_string_view.h b/nel/include/nel/misc/utf_string_view.h index 309377578..5b349a2d8 100644 --- a/nel/include/nel/misc/utf_string_view.h +++ b/nel/include/nel/misc/utf_string_view.h @@ -147,8 +147,8 @@ public: static void append(IStream &s, u32char c); static u32char get(IStream &s); - /// Get an UTF-8 string from an undefined ASCII-based codepage - static std::string fromAscii(std::string &str); + /// Get an UTF-8 string from an undefined ASCII-based codepage, without attempting to convert non-7-bit characters + static std::string fromAscii(const std::string &str); private: typedef u32char (*TIterator)(const void **addr); diff --git a/nel/src/3d/animation_set.cpp b/nel/src/3d/animation_set.cpp index 0b4c096c0..462587b09 100644 --- a/nel/src/3d/animation_set.cpp +++ b/nel/src/3d/animation_set.cpp @@ -289,7 +289,7 @@ void CAnimationSet::preloadSSSShapes(IDriver &drv, CShapeBank &shapeBank) std::set::iterator it; for(it=_SSSShapes.begin();it!=_SSSShapes.end();it++) { - string fileName= toLower(*it); + string fileName= toLowerAscii(*it); // link the shape to the shapeCache shapeBank.linkShapeToShapeCache(fileName, shapeCacheName); diff --git a/nel/src/3d/async_texture_manager.cpp b/nel/src/3d/async_texture_manager.cpp index a962c9991..22c4969ea 100644 --- a/nel/src/3d/async_texture_manager.cpp +++ b/nel/src/3d/async_texture_manager.cpp @@ -151,7 +151,7 @@ uint CAsyncTextureManager::addTextureRef(const string &textNameNotLwr, CMeshBa uint ret; // lower case name - string textName = toLower(textNameNotLwr); + string textName = toLowerAscii(textNameNotLwr); // find the texture in map ItTextureEntryMap it; diff --git a/nel/src/3d/coarse_mesh_build.cpp b/nel/src/3d/coarse_mesh_build.cpp index 966f389b4..e89c8da8d 100644 --- a/nel/src/3d/coarse_mesh_build.cpp +++ b/nel/src/3d/coarse_mesh_build.cpp @@ -117,7 +117,7 @@ bool CCoarseMeshBuild::buildBitmap (const std::vector& coarseMe if (texture->supportSharing()) { // Get sharing name - name+=toLower(texture->getShareName()); + name+=toLowerAscii(texture->getShareName()); } else { @@ -477,7 +477,7 @@ void CCoarseMeshBuild::remapCoordinates (const std::vector& coa if (texture->supportSharing()) { // Get sharing name - name+=toLower(texture->getShareName()); + name+=toLowerAscii(texture->getShareName()); } else { diff --git a/nel/src/3d/driver.cpp b/nel/src/3d/driver.cpp index 32cd19a89..71600d3c9 100644 --- a/nel/src/3d/driver.cpp +++ b/nel/src/3d/driver.cpp @@ -291,7 +291,7 @@ bool IDriver::invalidateShareTexture (ITexture &texture) void IDriver::getTextureShareName (const ITexture& tex, string &output) { // Create the shared Name. - output= toLower(tex.getShareName()); + output= toLowerAscii(tex.getShareName()); // append format Id of the texture. static char fmt[256]; @@ -372,7 +372,7 @@ void IDriver::profileTextureUsage(std::vector &result) // get the shareName string shareName; if(text->supportSharing()) - shareName= toLower(text->getShareName()); + shareName= toLowerAscii(text->getShareName()); else shareName= "Not Shared"; diff --git a/nel/src/3d/driver/opengl/driver_opengl.cpp b/nel/src/3d/driver/opengl/driver_opengl.cpp index 90b17958f..6fe9ae7c4 100644 --- a/nel/src/3d/driver/opengl/driver_opengl.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl.cpp @@ -2583,7 +2583,7 @@ void CDriverGL::retrieveATIDriverVersion() result = RegQueryValueExA(subKey, "DriverDesc", NULL, &valueType, (unsigned char *) driverDesc, &driverDescBufSize); if (result == ERROR_SUCCESS && valueType == REG_SZ) { - toLower(driverDesc); + toLowerAscii(driverDesc); if (strstr(driverDesc, "radeon")) // is it a radeon card ? { char driverVersion[256]; diff --git a/nel/src/3d/hls_texture_bank.cpp b/nel/src/3d/hls_texture_bank.cpp index b741ec387..9077f1638 100644 --- a/nel/src/3d/hls_texture_bank.cpp +++ b/nel/src/3d/hls_texture_bank.cpp @@ -59,7 +59,7 @@ uint32 CHLSTextureBank::addColorTexture(const CHLSColorTexture &tex) // *************************************************************************** void CHLSTextureBank::addTextureInstance(const std::string &name, uint32 colorTextureId, const vector &cols) { - string nameLwr= toLower(name); + string nameLwr= toLowerAscii(name); // checks nlassert(colorTextureId<_ColorTextures.size()); diff --git a/nel/src/3d/hls_texture_manager.cpp b/nel/src/3d/hls_texture_manager.cpp index 586ec53ce..3f585eb6b 100644 --- a/nel/src/3d/hls_texture_manager.cpp +++ b/nel/src/3d/hls_texture_manager.cpp @@ -76,7 +76,7 @@ sint CHLSTextureManager::findTexture(const std::string &name) const return -1; // Build a valid key. - string nameLwr= toLower(name); + string nameLwr= toLowerAscii(name); CHLSTextureBank::CTextureInstance textKey; CHLSTextureBank::CTextureInstanceHandle textKeyHandle; textKey.buildAsKey(nameLwr.c_str()); diff --git a/nel/src/3d/instance_lighter.cpp b/nel/src/3d/instance_lighter.cpp index 87e0deb45..a08a0a38f 100644 --- a/nel/src/3d/instance_lighter.cpp +++ b/nel/src/3d/instance_lighter.cpp @@ -415,7 +415,7 @@ void CInstanceLighter::light (const CInstanceGroup &igIn, CInstanceGroup &igOut, string name= _Instances[i].Name; bool shapeFound= true; - if (toLower (CFile::getExtension (name)) == "pacs_prim") + if (toLowerAscii (CFile::getExtension (name)) == "pacs_prim") { nlwarning("EXPORT BUG: Can't read %s (not a shape), should not be part of .ig!", name.c_str()); continue; diff --git a/nel/src/3d/landscapeig_manager.cpp b/nel/src/3d/landscapeig_manager.cpp index 10eab0f60..78154deda 100644 --- a/nel/src/3d/landscapeig_manager.cpp +++ b/nel/src/3d/landscapeig_manager.cpp @@ -115,7 +115,7 @@ void CLandscapeIGManager::initIG(UScene *scene, const std::string &igDesc, UDriv if (ig) { // add it to the map. - string tokId= toUpper(string(token)); + string tokId= toUpperAscii(string(token)); _ZoneInstanceGroupMap[tokId]= CInstanceGroupElement(ig, token); // Add a reference on the shapes @@ -129,7 +129,7 @@ void CLandscapeIGManager::initIG(UScene *scene, const std::string &igDesc, UDriv _ig.getShapeName(i, shapeName); if (!shapeName.empty ()) { - if (toLower(CFile::getExtension(shapeName)) != "pacs_prim") + if (toLowerAscii(CFile::getExtension(shapeName)) != "pacs_prim") { // Insert a new shape ? if (_ShapeAdded.find(shapeName) == _ShapeAdded.end()) @@ -295,7 +295,7 @@ UInstanceGroup *CLandscapeIGManager::getIG(const std::string &name) const std::string CLandscapeIGManager::translateName(const std::string &name) const { std::string ret; - ret= toUpper(name + ".ig"); + ret= toUpperAscii(name + ".ig"); return ret; } @@ -364,7 +364,7 @@ void CLandscapeIGManager::reloadAllIgs() const char *token= bkupIgFileNameList[i].c_str(); UInstanceGroup *ig = UInstanceGroup::createInstanceGroup(token); // add it to the map. - string tokId= toUpper(token); + string tokId= toUpperAscii(token); _ZoneInstanceGroupMap[tokId]= CInstanceGroupElement(ig, token); // If was addedToScene before, re-add to scene now. diff --git a/nel/src/3d/packed_zone.cpp b/nel/src/3d/packed_zone.cpp index f1cb7426b..fc8fa9a8a 100644 --- a/nel/src/3d/packed_zone.cpp +++ b/nel/src/3d/packed_zone.cpp @@ -665,7 +665,7 @@ void CPackedZone32::build(std::vector &leaves, { CMatrix instanceMatrix; igs[k]->getInstanceMatrix(l, instanceMatrix); - if (NLMISC::toLower(NLMISC::CFile::getExtension(igs[k]->getShapeName(l))) == "pacs_prim") continue; + if (NLMISC::toLowerAscii(NLMISC::CFile::getExtension(igs[k]->getShapeName(l))) == "pacs_prim") continue; std::string stdShapeName = standardizeShapeName(igs[k]->getShapeName(l)); TShapeCache::const_iterator it = shapeCache.find(stdShapeName); if (it != shapeCache.end()) diff --git a/nel/src/3d/scene.cpp b/nel/src/3d/scene.cpp index 15173d7d9..651837e2c 100644 --- a/nel/src/3d/scene.cpp +++ b/nel/src/3d/scene.cpp @@ -793,7 +793,7 @@ CTransformShape *CScene::createInstance(const string &shapeName) if (pMB->getAutoAnim()) { - std::string animName = toLower(CFile::getFilenameWithoutExtension(shapeName)); + std::string animName = toLowerAscii(CFile::getFilenameWithoutExtension(shapeName)); uint animID = _AutomaticAnimationSet->getAnimationIdByName(animName); if (animID != CAnimationSet::NotFound) { @@ -833,7 +833,7 @@ void CScene::createInstanceAsync(const string &shapeName, CTransformShape **pIns if (_ShapeBank->getPresentState( shapeName ) != CShapeBank::Present) { // Load it from file asynchronously - _ShapeBank->loadAsync( toLower(shapeName), getDriver(), position, NULL, selectedTexture); + _ShapeBank->loadAsync( toLowerAscii(shapeName), getDriver(), position, NULL, selectedTexture); } } diff --git a/nel/src/3d/scene_group.cpp b/nel/src/3d/scene_group.cpp index dc5dd9f73..131f5feaf 100644 --- a/nel/src/3d/scene_group.cpp +++ b/nel/src/3d/scene_group.cpp @@ -607,7 +607,7 @@ void CInstanceGroup::getShapeName (uint instanceIndex, std::string &shapeName) c shapeName = _TransformName->transformName (instanceIndex, rInstanceInfo.InstanceName, rInstanceInfo.Name); } - toLower(shapeName); + toLowerAscii(shapeName); if (!shapeName.empty() && shapeName.find('.') == std::string::npos) shapeName += ".shape"; } @@ -860,7 +860,7 @@ bool CInstanceGroup::addToSceneAsync (CScene& scene, IDriver *driver, uint selec shapeName = _TransformName->transformName (i, rInstanceInfo.InstanceName, rInstanceInfo.Name); } - toLower(shapeName); + toLowerAscii(shapeName); if (!shapeName.empty() && shapeName.find('.') == std::string::npos) shapeName += ".shape"; @@ -920,7 +920,7 @@ void CInstanceGroup::stopAddToSceneAsync () shapeName = rInstanceInfo.Name; } - toLower(shapeName); + toLowerAscii(shapeName); _AddToSceneTempScene->getShapeBank()->cancelLoadAsync (shapeName); } } diff --git a/nel/src/3d/shape_bank.cpp b/nel/src/3d/shape_bank.cpp index 71bdb79e2..cb6ea8c21 100644 --- a/nel/src/3d/shape_bank.cpp +++ b/nel/src/3d/shape_bank.cpp @@ -56,7 +56,7 @@ CShapeBank::~CShapeBank() IShape*CShapeBank::addRef(const string &shapeNameNotLwr) { - string shapeName= toLower(shapeNameNotLwr); + string shapeName= toLowerAscii(shapeNameNotLwr); // get the shape info (must succeed) TShapeInfoMap::iterator scfpmIt = ShapePtrToShapeInfo.find( getShapePtrFromShapeName( shapeName ) ); @@ -434,7 +434,7 @@ bool CShapeBank::processWSUploadTexture (CWaitingShape &rWS, uint32 &nTotalUploa CShapeBank::TShapeState CShapeBank::getPresentState (const string &shapeNameNotLwr) { - string shapeName= toLower(shapeNameNotLwr); + string shapeName= toLowerAscii(shapeNameNotLwr); // Is the shape is found in the shape map so return Present TShapeMap::iterator smIt = ShapeMap.find (shapeName); @@ -450,7 +450,7 @@ CShapeBank::TShapeState CShapeBank::getPresentState (const string &shapeNameNotL // *************************************************************************** IShape *CShapeBank::getShape (const std::string &shapeNameNotLwr) { - string shapeName= toLower(shapeNameNotLwr); + string shapeName= toLowerAscii(shapeNameNotLwr); // Is the shape is found in the shape map so return Present TShapeMap::iterator smIt = ShapeMap.find (shapeName); @@ -464,7 +464,7 @@ IShape *CShapeBank::getShape (const std::string &shapeNameNotLwr) void CShapeBank::load (const string &shapeNameNotLwr) { - string shapeName= toLower(shapeNameNotLwr); + string shapeName= toLowerAscii(shapeNameNotLwr); TShapeMap::iterator smIt = ShapeMap.find(shapeName); if( smIt == ShapeMap.end() ) @@ -498,7 +498,7 @@ void CShapeBank::load (const string &shapeNameNotLwr) void CShapeBank::loadAsync (const std::string &shapeNameNotLwr, IDriver *pDriver, const CVector &position, bool *bSignal, uint selectedTexture) { - string shapeName= toLower(shapeNameNotLwr); + string shapeName= toLowerAscii(shapeNameNotLwr); TShapeMap::iterator smIt = ShapeMap.find(shapeName); if (smIt != ShapeMap.end()) @@ -530,7 +530,7 @@ void CShapeBank::loadAsync (const std::string &shapeNameNotLwr, IDriver *pDriver void CShapeBank::cancelLoadAsync (const std::string &shapeNameNotLwr) { - string shapeName= toLower(shapeNameNotLwr); + string shapeName= toLowerAscii(shapeNameNotLwr); TWaitingShapesMap::iterator wsmmIt = WaitingShapes.find(shapeName); if (wsmmIt != WaitingShapes.end()) @@ -600,7 +600,7 @@ bool CShapeBank::isShapeWaiting () void CShapeBank::add (const string &shapeNameNotLwr, IShape* pShp) { nlassert(pShp); - string shapeName= toLower(shapeNameNotLwr); + string shapeName= toLowerAscii(shapeNameNotLwr); // request a system mem geometry copy? if(pShp && _ShapeNeedingSystemGeometryCopy.find(shapeName)!=_ShapeNeedingSystemGeometryCopy.end()) @@ -724,7 +724,7 @@ sint CShapeBank::getShapeCacheFreeSpace(const std::string &shapeCacheName) const void CShapeBank::linkShapeToShapeCache(const string &shapeNameNotLwr, const string &shapeCacheName) { - string shapeName= toLower(shapeNameNotLwr); + string shapeName= toLowerAscii(shapeNameNotLwr); for(;;) { @@ -857,7 +857,7 @@ void CShapeBank::preLoadShapes(const std::string &shapeCacheName, return; // lower case - string wildCard= toLower(wildCardNotLwr); + string wildCard= toLowerAscii(wildCardNotLwr); // For all files for(uint i=0;iprogress ((float)i/(float)listFile.size ()); - string fileName= toLower(CFile::getFilename(listFile[i])); + string fileName= toLowerAscii(CFile::getFilename(listFile[i])); // if the file is ok for the wildCard, process it if( testWildCard(fileName.c_str(), wildCard.c_str()) ) { @@ -908,7 +908,7 @@ void CShapeBank::preLoadShapes(const std::string &shapeCacheName, // *************************************************************************** void CShapeBank::buildSystemGeometryForshape(const std::string &shapeName) { - _ShapeNeedingSystemGeometryCopy.insert(toLower(shapeName)); + _ShapeNeedingSystemGeometryCopy.insert(toLowerAscii(shapeName)); } diff --git a/nel/src/3d/shape_info.cpp b/nel/src/3d/shape_info.cpp index d3a8a4df3..4385b044e 100644 --- a/nel/src/3d/shape_info.cpp +++ b/nel/src/3d/shape_info.cpp @@ -229,7 +229,7 @@ void CShapeInfo::build(const CMeshBase &meshBase, const CMeshMRMGeom &meshGeom) // *************************************************************************** std::string standardizeShapeName(const std::string &name) { - std::string result = NLMISC::toLower(name); + std::string result = NLMISC::toLowerAscii(name); if (CFile::getExtension(result).empty()) { result += ".shape"; diff --git a/nel/src/3d/texture_file.cpp b/nel/src/3d/texture_file.cpp index 0e343ec8e..58f2f333f 100644 --- a/nel/src/3d/texture_file.cpp +++ b/nel/src/3d/texture_file.cpp @@ -311,7 +311,7 @@ void CTextureFile::setMipMapSkipAtLoad(uint8 level) // *************************************************************************** std::string CTextureFile::getShareName() const { - return toLower(_FileName); + return toLowerAscii(_FileName); } diff --git a/nel/src/3d/tile_bank.cpp b/nel/src/3d/tile_bank.cpp index a22a797f4..9ba3ca756 100644 --- a/nel/src/3d/tile_bank.cpp +++ b/nel/src/3d/tile_bank.cpp @@ -275,7 +275,7 @@ sint CTileBank::getNumBitmap (CTile::TBitmap bitmap) const { std::vector vect (str.length()+1); memcpy (&*vect.begin(), str.c_str(), str.length()+1); - toLower(&*vect.begin()); + toLowerAscii(&*vect.begin()); setString.insert (std::string (&*vect.begin())); } } @@ -600,7 +600,7 @@ void CTileBank::removeDisplacementMap (uint mapId) uint CTileBank::getDisplacementMap (const string &fileName) { // Lower string - string lower=toLower(fileName); + string lower=toLowerAscii(fileName); // Look for this texture filename uint noiseTile; diff --git a/nel/src/georges/form.cpp b/nel/src/georges/form.cpp index 40f374b8d..2f9ecf9b1 100644 --- a/nel/src/georges/form.cpp +++ b/nel/src/georges/form.cpp @@ -371,7 +371,7 @@ void CForm::warning (bool exception, const std::string &function, const char *fo void CForm::getDependencies (std::set &dependencies) const { // Add me - if (dependencies.insert (toLower(CFile::getFilename (_Filename))).second) + if (dependencies.insert (toLowerAscii(CFile::getFilename (_Filename))).second) { // Add parents uint i; diff --git a/nel/src/georges/form_dfn.cpp b/nel/src/georges/form_dfn.cpp index d9c52c1b4..628077579 100644 --- a/nel/src/georges/form_dfn.cpp +++ b/nel/src/georges/form_dfn.cpp @@ -882,7 +882,7 @@ void CFormDfn::warning (bool exception, const std::string &function, const char void CFormDfn::getDependencies (std::set &dependencies) const { // Scan only if not already inserted - if (dependencies.insert (toLower(CFile::getFilename (_Filename))).second) + if (dependencies.insert (toLowerAscii(CFile::getFilename (_Filename))).second) { // Add parents uint i; @@ -898,7 +898,7 @@ void CFormDfn::getDependencies (std::set &dependencies) const Entries[i].getDfnPtr ()->getDependencies (dependencies); if (Entries[i].getTypePtr ()) { - dependencies.insert (toLower(CFile::getFilename (Entries[i].getFilename()))); + dependencies.insert (toLowerAscii(CFile::getFilename (Entries[i].getFilename()))); } } } diff --git a/nel/src/georges/form_loader.cpp b/nel/src/georges/form_loader.cpp index 877c587ed..dd3d50ed5 100644 --- a/nel/src/georges/form_loader.cpp +++ b/nel/src/georges/form_loader.cpp @@ -67,7 +67,7 @@ CFormLoader::~CFormLoader() CType *CFormLoader::loadType (const std::string &filename) { // Lower string filename - string lowerStr = toLower(filename); + string lowerStr = toLowerAscii(filename); lowerStr = CFile::getFilename (lowerStr); // Already in the map ? @@ -137,7 +137,7 @@ CType *CFormLoader::loadType (const std::string &filename) CFormDfn *CFormLoader::loadFormDfn (const std::string &filename, bool forceLoad) { // Lower string filename - string lowerStr = toLower(filename); + string lowerStr = toLowerAscii(filename); lowerStr = CFile::getFilename (lowerStr); // Already in the map ? @@ -203,7 +203,7 @@ CFormDfn *CFormLoader::loadFormDfn (const std::string &filename, bool forceLoad) UForm *CFormLoader::loadForm (const std::string &filename) { // Lower string filename - string lowerStr = toLower((string)filename); + string lowerStr = toLowerAscii((string)filename); lowerStr = CFile::getFilename (lowerStr); // Already in the map ? diff --git a/nel/src/gui/action_handler.cpp b/nel/src/gui/action_handler.cpp index a10513ebb..f7a5f2cee 100644 --- a/nel/src/gui/action_handler.cpp +++ b/nel/src/gui/action_handler.cpp @@ -73,13 +73,13 @@ namespace NLGUI { string allparam = Params; skipBlankAtStart (allparam); - string param = toLower (ParamName); + string param = toLowerAscii (ParamName); while (!allparam.empty()) { std::string::size_type e = allparam.find('='); if (e == std::string::npos || e == 0) break; std::string::size_type p = allparam.find('|'); - string tmp = NLMISC::toLower(allparam.substr(0,e)); + string tmp = NLMISC::toLowerAscii(allparam.substr(0,e)); skipBlankAtEnd(tmp); if (tmp == param) { @@ -105,7 +105,7 @@ namespace NLGUI std::string::size_type e = allparam.find('='); if (e == std::string::npos || e == 0) break; std::string::size_type p = allparam.find('|'); - string tmp = NLMISC::toLower(allparam.substr(0,e)); + string tmp = NLMISC::toLowerAscii(allparam.substr(0,e)); skipBlankAtEnd(tmp); string tmp2 = allparam.substr(e+1,p-e-1); diff --git a/nel/src/gui/css_parser.cpp b/nel/src/gui/css_parser.cpp index d43189fca..ab9f6edb7 100644 --- a/nel/src/gui/css_parser.cpp +++ b/nel/src/gui/css_parser.cpp @@ -50,7 +50,7 @@ namespace NLGUI pos = elements[i].find_first_of(':'); if (pos != std::string::npos) { - std::string key = trim(toLower(elements[i].substr(0, pos))); + std::string key = trim(toLowerAscii(elements[i].substr(0, pos))); std::string value = trim(elements[i].substr(pos+1)); styles.push_back(TStylePair(key, value)); } @@ -361,7 +361,7 @@ namespace NLGUI while(pos < sel.size() && is_nmchar(sel[pos])) pos++; - current.Element = toLower(sel.substr(start, pos - start)); + current.Element = toLowerAscii(sel.substr(start, pos - start)); start = pos; continue; } @@ -374,7 +374,7 @@ namespace NLGUI while(pos < sel.size() && is_nmchar(sel[pos])) pos++; - current.Id = toLower(sel.substr(start, pos - start)); + current.Id = toLowerAscii(sel.substr(start, pos - start)); start = pos; } else if (sel[pos] == '.') @@ -386,7 +386,7 @@ namespace NLGUI while(pos < sel.size() && (is_nmchar(sel[pos]) || sel[pos] == '.')) pos++; - current.setClass(toLower(sel.substr(start, pos - start))); + current.setClass(toLowerAscii(sel.substr(start, pos - start))); start = pos; } else if (sel[pos] == '[') @@ -552,7 +552,7 @@ namespace NLGUI } } - std::string key = toLower(sel.substr(start, pos - start)); + std::string key = toLowerAscii(sel.substr(start, pos - start)); if (key.empty()) { failed = true; diff --git a/nel/src/gui/css_selector.cpp b/nel/src/gui/css_selector.cpp index 2c9d94559..18d0375b0 100644 --- a/nel/src/gui/css_selector.cpp +++ b/nel/src/gui/css_selector.cpp @@ -59,7 +59,7 @@ namespace NLGUI void CCssSelector::setClass(const std::string &cls) { std::vector parts; - NLMISC::splitString(toLower(cls), ".", parts); + NLMISC::splitString(toLowerAscii(cls), ".", parts); for(uint i = 0; i< parts.size(); i++) { @@ -80,7 +80,7 @@ namespace NLGUI } else { - Attr.push_back(SAttribute(key, toLower(val), op, cs)); + Attr.push_back(SAttribute(key, toLowerAscii(val), op, cs)); } } @@ -146,7 +146,7 @@ namespace NLGUI // case-insensitive compare, Attr.value is already lowercased if (!Attr[i].caseSensitive) { - value = toLower(value); + value = toLowerAscii(value); } switch(Attr[i].op) @@ -255,7 +255,7 @@ namespace NLGUI if (start == std::string::npos) return; - std::string expr = toLower(pseudo.substr(start, end - start)); + std::string expr = toLowerAscii(pseudo.substr(start, end - start)); if (expr.empty()) return; diff --git a/nel/src/gui/css_style.cpp b/nel/src/gui/css_style.cpp index 396bff062..ac36da726 100644 --- a/nel/src/gui/css_style.cpp +++ b/nel/src/gui/css_style.cpp @@ -676,7 +676,7 @@ namespace NLGUI else if (it->first == "text-decoration" || it->first == "text-decoration-line") { - std::string prop(toLower(it->second)); + std::string prop(toLowerAscii(it->second)); style.Underlined = (prop.find("underline") != std::string::npos); style.StrikeThrough = (prop.find("line-through") != std::string::npos); } @@ -924,7 +924,7 @@ namespace NLGUI { // normalize std::string image = trim(it->second); - if (toLower(image.substr(0, 4)) == "url(") + if (toLowerAscii(image.substr(0, 4)) == "url(") { image = image.substr(4, image.size()-5); } @@ -934,7 +934,7 @@ namespace NLGUI if (it->first == "background-repeat") { // normalize - std::string val = toLower(trim(it->second)); + std::string val = toLowerAscii(trim(it->second)); std::vector parts; splitParams(val, ' ', parts); // check for "repeat repeat" @@ -947,7 +947,7 @@ namespace NLGUI if (it->first == "background-size") { // normalize - std::string val = toLower(trim(it->second)); + std::string val = toLowerAscii(trim(it->second)); std::vector parts; splitParams(val, ' ', parts); if (parts.size() == 2 && parts[0] == parts[1]) @@ -999,7 +999,7 @@ namespace NLGUI uint index = 0; while(!failed && index < parts.size()) { - std::string val = toLower(parts[index]); + std::string val = toLowerAscii(parts[index]); bool matches = false; for(uint i = 0; i < nbProps; i++) { @@ -1028,7 +1028,7 @@ namespace NLGUI // second loop -> false && break loop = !loop; - val = toLower(parts[next]); + val = toLowerAscii(parts[next]); if (val == "center") { if (bgPositionX.empty()) bgPositionX = "center"; @@ -1082,7 +1082,7 @@ namespace NLGUI uint next = index + 1; if (next < parts.size()) { - val = toLower(parts[next]); + val = toLowerAscii(parts[next]); if (val == "cover" || val == "contain") { matches = true; @@ -1106,7 +1106,7 @@ namespace NLGUI next++; if (next < parts.size()) { - val = toLower(parts[next]); + val = toLowerAscii(parts[next]); if (val == "auto") v = "auto"; else if (getCssLength(fval, unit, val)) @@ -1160,7 +1160,7 @@ namespace NLGUI uint next = index + 1; if (next < parts.size()) { - val = toLower(parts[next]); + val = toLowerAscii(parts[next]); if (val == "repeat" || val == "space" || val == "round" || val == "no-repeat") { vert = val; @@ -1334,7 +1334,7 @@ namespace NLGUI bool CCssStyle::tryBorderWidthShorthand(const std::string &prop, const std::string &value, TStyle &style) const { std::vector parts; - splitParams(toLower(value), ' ', parts); + splitParams(toLowerAscii(value), ' ', parts); float tmpf; std::string unit; @@ -1371,7 +1371,7 @@ namespace NLGUI bool CCssStyle::tryBorderStyleShorthand(const std::string &prop, const std::string &value, TStyle &style) const { std::vector parts; - splitParams(toLower(value), ' ', parts); + splitParams(toLowerAscii(value), ' ', parts); // verify that parts are valid uint8 maxSize = (prop == "border" || prop == "border-style") ? 4 : 1; @@ -1420,7 +1420,7 @@ namespace NLGUI bool CCssStyle::tryBorderColorShorthand(const std::string &prop, const std::string &value, TStyle &style) const { std::vector parts; - splitParams(toLower(value), ' ', parts); + splitParams(toLowerAscii(value), ' ', parts); CRGBA color; // verify that parts are valid @@ -1465,7 +1465,7 @@ namespace NLGUI TStyle borderStyle; std::vector parts; - splitParams(toLower(value), ' ', parts); + splitParams(toLowerAscii(value), ' ', parts); for(uint index = 0; index < parts.size(); ++index) { @@ -1530,7 +1530,7 @@ namespace NLGUI void CCssStyle::expandPaddingShorthand(const std::string &value, TStyle &style) const { std::vector parts; - splitParams(toLower(value), ' ', parts); + splitParams(toLowerAscii(value), ' ', parts); uint8 t, r, b, l; if (!getShorthandIndices(parts.size(), t, r, b, l)) diff --git a/nel/src/gui/ctrl_base.cpp b/nel/src/gui/ctrl_base.cpp index 2e95c50dd..e120c5d4e 100644 --- a/nel/src/gui/ctrl_base.cpp +++ b/nel/src/gui/ctrl_base.cpp @@ -100,7 +100,7 @@ namespace NLGUI CCtrlBase::TToolTipParentType CCtrlBase::stringToToolTipParent( const std::string &str ) { - std::string s = toLower( str ); + std::string s = toLowerAscii( str ); if( s == "mouse" ) return TTMouse; diff --git a/nel/src/gui/ctrl_base_button.cpp b/nel/src/gui/ctrl_base_button.cpp index dec715048..68aa19f15 100644 --- a/nel/src/gui/ctrl_base_button.cpp +++ b/nel/src/gui/ctrl_base_button.cpp @@ -584,18 +584,18 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_l" ); if (prop) { - _ListMenuLeft = NLMISC::toLower(std::string((const char *) prop)); + _ListMenuLeft = NLMISC::toLowerAscii(std::string((const char *) prop)); } prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); if (prop) { - _ListMenuRight = NLMISC::toLower(std::string((const char *) prop)); + _ListMenuRight = NLMISC::toLowerAscii(std::string((const char *) prop)); } // list menu on both clicks prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_b" ); if (prop) { - setListMenuBoth(NLMISC::toLower(std::string((const char *) prop))); + setListMenuBoth(NLMISC::toLowerAscii(std::string((const char *) prop))); } prop= (char*) xmlGetProp (cur, (xmlChar*)"frozen"); diff --git a/nel/src/gui/ctrl_button.cpp b/nel/src/gui/ctrl_button.cpp index e27d8cfbd..cc38e50e4 100644 --- a/nel/src/gui/ctrl_button.cpp +++ b/nel/src/gui/ctrl_button.cpp @@ -210,21 +210,21 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" ); if (prop) { - string TxName = NLMISC::toLower((const char *) prop); + string TxName = NLMISC::toLowerAscii((const char *) prop); _TextureIdNormal.setTexture(TxName.c_str()); } prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" ); if (prop) { - string TxName = NLMISC::toLower((const char *) prop); + string TxName = NLMISC::toLowerAscii((const char *) prop); _TextureIdPushed.setTexture(TxName.c_str()); } prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" ); if (prop) { - string TxName = NLMISC::toLower((const char *) prop); + string TxName = NLMISC::toLowerAscii((const char *) prop); _TextureIdOver.setTexture(TxName.c_str()); } diff --git a/nel/src/gui/ctrl_col_pick.cpp b/nel/src/gui/ctrl_col_pick.cpp index 411414de7..251c655c2 100644 --- a/nel/src/gui/ctrl_col_pick.cpp +++ b/nel/src/gui/ctrl_col_pick.cpp @@ -212,12 +212,12 @@ namespace NLGUI CViewRenderer &rVR = *CViewRenderer::getInstance(); if(prop) { - string sTmp = NLMISC::toLower((const char*)prop); + string sTmp = NLMISC::toLowerAscii((const char*)prop); _Texture = rVR.createTexture (sTmp, 0, 0, 256, 64, false, false); } prop = (char*) xmlGetProp( node, (xmlChar*)"onchange" ); - if (prop) _AHOnChange = NLMISC::toLower((const char*)prop); + if (prop) _AHOnChange = NLMISC::toLowerAscii((const char*)prop); prop = (char*) xmlGetProp( node, (xmlChar*)"onchange_params" ); if (prop) _AHOnChangeParams = string((const char*)prop); diff --git a/nel/src/gui/ctrl_scroll.cpp b/nel/src/gui/ctrl_scroll.cpp index d9191e770..00f089660 100644 --- a/nel/src/gui/ctrl_scroll.cpp +++ b/nel/src/gui/ctrl_scroll.cpp @@ -561,17 +561,17 @@ namespace NLGUI // Read Action handlers prop = (char*) xmlGetProp( node, (xmlChar*)"onscroll" ); - if (prop) _AHOnScroll = NLMISC::toLower(prop.str()); + if (prop) _AHOnScroll = NLMISC::toLowerAscii(prop.str()); prop = (char*) xmlGetProp( node, (xmlChar*)"params" ); if (prop) _AHOnScrollParams = string((const char*)prop); // prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollend" ); - if (prop) _AHOnScrollEnd = NLMISC::toLower(prop.str()); + if (prop) _AHOnScrollEnd = NLMISC::toLowerAscii(prop.str()); prop = (char*) xmlGetProp( node, (xmlChar*)"end_params" ); if (prop) _AHOnScrollEndParams = string((const char*)prop); // prop = (char*) xmlGetProp( node, (xmlChar*)"onscrollcancel" ); - if (prop) _AHOnScrollCancel = NLMISC::toLower(prop.str()); + if (prop) _AHOnScrollCancel = NLMISC::toLowerAscii(prop.str()); prop = (char*) xmlGetProp( node, (xmlChar*)"cancel_params" ); if (prop) _AHOnScrollCancelParams = string((const char*)prop); diff --git a/nel/src/gui/ctrl_text_button.cpp b/nel/src/gui/ctrl_text_button.cpp index 3be6142e3..e7689704f 100644 --- a/nel/src/gui/ctrl_text_button.cpp +++ b/nel/src/gui/ctrl_text_button.cpp @@ -542,7 +542,7 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_normal" ); if (prop) { - string TxName = toLower(std::string((const char *) prop)); + string TxName = toLowerAscii(std::string((const char *) prop)); _TextureIdNormal[0].setTexture((TxName+"_l.tga").c_str()); _TextureIdNormal[1].setTexture((TxName+"_m.tga").c_str()); _TextureIdNormal[2].setTexture((TxName+"_r.tga").c_str()); @@ -551,7 +551,7 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_pushed" ); if (prop) { - string TxName = toLower(std::string((const char *) prop)); + string TxName = toLowerAscii(std::string((const char *) prop)); _TextureIdPushed[0].setTexture((TxName+"_l.tga").c_str()); _TextureIdPushed[1].setTexture((TxName+"_m.tga").c_str()); _TextureIdPushed[2].setTexture((TxName+"_r.tga").c_str()); @@ -560,7 +560,7 @@ namespace NLGUI prop = (char*) xmlGetProp( cur, (xmlChar*)"tx_over" ); if (prop) { - string TxName = toLower(std::string((const char *) prop)); + string TxName = toLowerAscii(std::string((const char *) prop)); _TextureIdOver[0].setTexture((TxName+"_l.tga").c_str()); _TextureIdOver[1].setTexture((TxName+"_m.tga").c_str()); _TextureIdOver[2].setTexture((TxName+"_r.tga").c_str()); diff --git a/nel/src/gui/dbgroup_combo_box.cpp b/nel/src/gui/dbgroup_combo_box.cpp index 725019b72..1e5f18b4d 100644 --- a/nel/src/gui/dbgroup_combo_box.cpp +++ b/nel/src/gui/dbgroup_combo_box.cpp @@ -45,7 +45,8 @@ namespace NLGUI // Compare strings static inline bool lt_text(const std::pair &s1, const std::pair &s2) { - return toLower(s1.second) < toLower(s2.second); + // return toLower(s1.second) < toLower(s2.second); + return -NLMISC::compareCaseInsensitive(s1.second, s2.second); } std::string CDBGroupComboBox::measureMenu; diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp index 27084dd1b..f90eb424f 100644 --- a/nel/src/gui/group_editbox.cpp +++ b/nel/src/gui/group_editbox.cpp @@ -629,7 +629,7 @@ namespace NLGUI } prop = (char*) xmlGetProp( cur, (xmlChar*)"menu_r" ); - if (prop) _ListMenuRight = toLower((const char *) prop); + if (prop) _ListMenuRight = toLowerAscii((const char *) prop); prop = (char*) xmlGetProp( cur, (xmlChar*)"max_historic" ); if (prop) fromString((const char*)prop, _MaxHistoric); diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index 508d60361..04c083c20 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -89,7 +89,7 @@ namespace NLGUI // Return URL with https is host is in HSTS list static std::string upgradeInsecureUrl(const std::string &url) { - if (toLower(url.substr(0, 7)) != "http://") { + if (toLowerAscii(url.substr(0, 7)) != "http://") { return url; } @@ -136,7 +136,7 @@ namespace NLGUI if (pos == std::string::npos) return; - std::string key = toLower(header.substr(0, pos)); + std::string key = toLowerAscii(header.substr(0, pos)); if (pos != std::string::npos) { HeadersRecv[key] = header.substr(pos + 2); @@ -185,7 +185,7 @@ namespace NLGUI bool hasHSTSHeader() { // ignore header if not secure connection - if (toLower(Url.substr(0, 8)) != "https://") + if (toLowerAscii(Url.substr(0, 8)) != "https://") { return false; } @@ -552,7 +552,7 @@ namespace NLGUI LOG_DL("curl easy handle %p created for '%s'", curl, download.url.c_str()); // https:// - if (toLower(download.url.substr(0, 8)) == "https://") + if (toLowerAscii(download.url.substr(0, 8)) == "https://") { // if supported, use custom SSL context function to load certificates NLWEB::CCurlCertificates::useCertificates(curl); @@ -1266,7 +1266,7 @@ namespace NLGUI // TODO: 'content' should already be tokenized in css parser as it has all the functions for that std::string content = trim(_Style.getStyle("content")); - if (toLower(content) == "none" || toLower(content) == "normal") + if (toLowerAscii(content) == "none" || toLowerAscii(content) == "normal") { _Style.popStyle(); return; @@ -1297,7 +1297,7 @@ namespace NLGUI // skip closing quote pos++; } - else if (content[pos] == 'u' && pos < content.size() - 6 && toLower(content.substr(pos, 4)) == "url(") + else if (content[pos] == 'u' && pos < content.size() - 6 && toLowerAscii(content.substr(pos, 4)) == "url(") { // url(/path-to/image.jpg) / "Alt!" // url("/path to/image.jpg") / "Alt!" @@ -3440,7 +3440,7 @@ namespace NLGUI result = url; string tmp; - if (toLower(result).find("file:") == 0 && result.size() > 5) + if (toLowerAscii(result).find("file:") == 0 && result.size() > 5) { result = result.substr(5, result.size()-5); } @@ -3461,7 +3461,7 @@ namespace NLGUI { // Normalize the path if (isUrl) - //result = "file:"+toLower(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/ + //result = "file:"+toLowerAscii(CPath::standardizePath (CPath::getFullPath (CFile::getPath(result)))+CFile::getFilename(result));*/ result = "file:/"+tmp; else result = tmp; @@ -3786,7 +3786,7 @@ namespace NLGUI updateRefreshButton(); std::string filename; - if (toLower(uri).find("file:/") == 0) + if (toLowerAscii(uri).find("file:/") == 0) { filename = uri.substr(6, uri.size() - 6); } @@ -3856,7 +3856,7 @@ namespace NLGUI } // https:// - if (toLower(url.substr(0, 8)) == "https://") + if (toLowerAscii(url.substr(0, 8)) == "https://") { // if supported, use custom SSL context function to load certificates NLWEB::CCurlCertificates::useCertificates(curl); @@ -5347,7 +5347,7 @@ namespace NLGUI if (_Style.hasStyle("text-align")) align = _Style.Current.TextAlign; else if (elm.hasNonEmptyAttribute("align")) - align = toLower(elm.getAttribute("align")); + align = toLowerAscii(elm.getAttribute("align")); if (align == "left") cellParams.Align = CGroupCell::Left; @@ -5362,7 +5362,7 @@ namespace NLGUI if (_Style.hasStyle("vertical-align")) valign = _Style.Current.VerticalAlign; else if (elm.hasNonEmptyAttribute("valign")) - valign = toLower(elm.getAttribute("valign")); + valign = toLowerAscii(elm.getAttribute("valign")); if (valign == "top") cellParams.VAlign = CGroupCell::Top; @@ -5859,7 +5859,7 @@ namespace NLGUI // Build the form CGroupHTML::CForm form; // id check is case sensitive and auto id's are uppercase - form.id = toLower(trim(elm.getAttribute("id"))); + form.id = toLowerAscii(trim(elm.getAttribute("id"))); if (form.id.empty()) { form.id = toString("FORM%d", _Forms.size()); @@ -6287,7 +6287,7 @@ namespace NLGUI { fromString(httpContent.substr(0, pos), _NextRefreshTime); - pos = toLower(httpContent).find("url="); + pos = toLowerAscii(httpContent).find("url="); if (pos != string::npos) _RefreshUrl = getAbsoluteUrl(httpContent.substr(pos + 4)); } diff --git a/nel/src/gui/html_parser.cpp b/nel/src/gui/html_parser.cpp index 3d7303706..de1a0e4d9 100644 --- a/nel/src/gui/html_parser.cpp +++ b/nel/src/gui/html_parser.cpp @@ -89,7 +89,7 @@ namespace NLGUI } } - parent.Children.push_back(CHtmlElement(CHtmlElement::ELEMENT_NODE, toLower((const char*)node->name))); + parent.Children.push_back(CHtmlElement(CHtmlElement::ELEMENT_NODE, toLowerAscii((const char*)node->name))); CHtmlElement &elm = parent.Children.back(); elm.ID = element_number; elm.parent = &parent; @@ -109,7 +109,7 @@ namespace NLGUI elm.Attributes.clear(); for (xmlAttr *cur_attr = node->properties; cur_attr; cur_attr = cur_attr->next) { - std::string key(toLower((const char *)(cur_attr->name))); + std::string key(toLowerAscii((const char *)(cur_attr->name))); std::string value; if (cur_attr->children) { @@ -124,7 +124,7 @@ namespace NLGUI NLMISC::splitString(elm.getAttribute("class"), " ", parts); for(uint i = 0; i for ingame browser @@ -154,7 +154,7 @@ namespace NLGUI bool useStyle = true; if (elm.hasAttribute("media")) { - std::string media = trim(toLower(elm.Attributes["media"])); + std::string media = trim(toLowerAscii(elm.Attributes["media"])); useStyle = media.empty() || media.find("all") != std::string::npos || media.find("screen") != std::string::npos; //