diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index 9271f2fc9..e0fb4f256 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -544,7 +544,7 @@ std::vector FGAIBase::resolveModelPath(ModelSearchOrder searchOrder for (SGPath p : globals->get_data_paths("AI")) { p.append(model_path); if (p.exists()) { - SG_LOG(SG_AI, SG_DEBUG, "Found AI model: " << p.local8BitStr()); + SG_LOG(SG_AI, SG_DEBUG, "Found AI model: " << p); path_list.push_back(p.local8BitStr()); break; } diff --git a/src/Canvas/FGCanvasSystemAdapter.cxx b/src/Canvas/FGCanvasSystemAdapter.cxx index bacb73d97..7743b020e 100644 --- a/src/Canvas/FGCanvasSystemAdapter.cxx +++ b/src/Canvas/FGCanvasSystemAdapter.cxx @@ -52,7 +52,7 @@ namespace canvas "canvas::Text: using font file " << path ); - simgear::canvas::FontPtr font = osgText::readFontFile(path.local8BitStr()); + simgear::canvas::FontPtr font = osgText::readFontFile(path.utf8Str()); if( !font ) SG_LOG ( @@ -86,9 +86,9 @@ namespace canvas SGPath valid_path = fgValidatePath(p, false); if( !valid_path.isNull() ) #if OSG_VERSION_LESS_THAN(3,4,0) - return osgDB::readRefImageFile(valid_path.local8BitStr()); + return osgDB::readRefImageFile(valid_path.utf8Str()); #else - return osgDB::readRefImageFile(valid_path.local8BitStr()); + return osgDB::readRefImageFile(valid_path.utf8Str()); #endif SG_LOG(SG_IO, SG_ALERT, "canvas::Image: reading '" << path << "' denied"); @@ -98,9 +98,9 @@ namespace canvas SGPath tpath = globals->resolve_resource_path(path); if( !tpath.isNull() ) #if OSG_VERSION_LESS_THAN(3,4,0) - return osgDB::readImageFile(tpath.local8BitStr()); + return osgDB::readImageFile(tpath.utf8Str()); #else - return osgDB::readRefImageFile(tpath.local8BitStr()); + return osgDB::readRefImageFile(tpath.utf8Str()); #endif SG_LOG(SG_IO, SG_ALERT, "canvas::Image: No such image: '" << path << "'"); diff --git a/src/Cockpit/NavDisplay.cxx b/src/Cockpit/NavDisplay.cxx index bfabb9065..9885d81ff 100644 --- a/src/Cockpit/NavDisplay.cxx +++ b/src/Cockpit/NavDisplay.cxx @@ -777,7 +777,7 @@ NavDisplay::updateFont() } osg::ref_ptr fontOptions = new osgDB::ReaderWriter::Options("monochrome"); - osg::ref_ptr font = osgText::readFontFile(tpath.local8BitStr(), fontOptions.get()); + osg::ref_ptr font = osgText::readFontFile(tpath.utf8Str(), fontOptions.get()); if (font != 0) { _font = font; diff --git a/src/Cockpit/wxradar.cxx b/src/Cockpit/wxradar.cxx index 1165d93de..61a1b49bd 100644 --- a/src/Cockpit/wxradar.cxx +++ b/src/Cockpit/wxradar.cxx @@ -1084,7 +1084,7 @@ wxRadarBg::updateFont() } osg::ref_ptr fontOptions = new osgDB::ReaderWriter::Options("monochrome"); - osg::ref_ptr font = osgText::readFontFile(tpath.local8BitStr(), fontOptions.get()); + osg::ref_ptr font = osgText::readFontFile(tpath.utf8Str(), fontOptions.get()); if (font != 0) { _font = font; diff --git a/src/Environment/ephemeris.cxx b/src/Environment/ephemeris.cxx index db9d59b1e..046e50084 100644 --- a/src/Environment/ephemeris.cxx +++ b/src/Environment/ephemeris.cxx @@ -54,7 +54,7 @@ void Ephemeris::init() { SGPath ephem_data_path(globals->get_fg_root()); ephem_data_path.append("Astro"); - _impl.reset(new SGEphemeris(ephem_data_path.local8BitStr())); + _impl.reset(new SGEphemeris(ephem_data_path)); tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs); tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys); diff --git a/src/GUI/AddonsModel.cxx b/src/GUI/AddonsModel.cxx index 1d605051d..ba4ee041f 100644 --- a/src/GUI/AddonsModel.cxx +++ b/src/GUI/AddonsModel.cxx @@ -37,7 +37,7 @@ AddonsModel::AddonsModel(QObject* pr) : int roleValue = IdRole; for (auto it = m_roles.begin(); it != m_roles.end(); ++it) { - QByteArray name = (*it).toLocal8Bit(); + QByteArray name = it->toUtf8(); m_roleToName[roleValue] = name; m_nameToRole[*it] = roleValue++; } diff --git a/src/GUI/FGFontCache.cxx b/src/GUI/FGFontCache.cxx index fda16272b..6c6b02d20 100644 --- a/src/GUI/FGFontCache.cxx +++ b/src/GUI/FGFontCache.cxx @@ -27,6 +27,7 @@ #include #include +#include #include
@@ -211,26 +212,19 @@ FGFontCache::getfntpath(const std::string& name) bool FGFontCache::initializeFonts() { - static std::string fontext("txf"); + static std::string fontext(",txf"); init(); - std::string fontPath = _path.local8BitStr(); - ulDir* fontdir = ulOpenDir(fontPath.c_str()); - if (!fontdir) - return false; - const ulDirEnt *dirEntry; - while ((dirEntry = ulReadDir(fontdir)) != 0) { - SGPath path(_path); - path.append(dirEntry->d_name); - if (path.extension() == fontext) { - fntTexFont* f = new fntTexFont; - std::string ps = path.local8BitStr(); - if (f->load(ps.c_str())) - _texFonts[std::string(dirEntry->d_name)] = f; - else - delete f; - } + + auto dir = simgear::Dir(_path); + for (auto p : dir.children(simgear::Dir::TYPE_FILE, fontext)) { + fntTexFont* f = new fntTexFont; + // FIXME : this will fail when fonts are on UTF8 paths + if (f->load(p.local8BitStr())) + _texFonts[p.file()] = f; + else + delete f; } - ulCloseDir(fontdir); + return true; } diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index cfdda7660..2ff531d71 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -483,7 +483,7 @@ bool fgInitHome() } char buf[16]; - std::string ps = pidPath.local8BitStr(); + std::string ps = pidPath.utf8Str(); // do open+unlink trick to the file is deleted on exit, even if we // crash or exit(-1) @@ -873,8 +873,7 @@ void fgCreateSubsystems(bool duringReset) { SGPath mpath( globals->get_fg_root() ); mpath.append( fgGetString("/sim/rendering/materials-file") ); - if ( ! globals->get_matlib()->load(globals->get_fg_root().local8BitStr(), mpath.local8BitStr(), - globals->get_props()) ) { + if ( ! globals->get_matlib()->load(globals->get_fg_root(), mpath, globals->get_props()) ) { throw sg_io_exception("Error loading materials file", mpath); } diff --git a/src/Main/globals.cxx b/src/Main/globals.cxx index bb9b5d9f4..1d5025b47 100644 --- a/src/Main/globals.cxx +++ b/src/Main/globals.cxx @@ -364,9 +364,7 @@ void FGGlobals::append_fg_scenery (const SGPath &path) // tell the ResouceManager about the scenery path // needed to load Models from this scenery path - simgear::ResourceManager::instance()->addBasePath(abspath.local8BitStr(), - simgear::ResourceManager::PRIORITY_DEFAULT); - simgear::Dir dir(abspath); + simgear::ResourceManager::instance()->addBasePath(abspath, simgear::ResourceManager::PRIORITY_DEFAULT); fg_scenery.push_back(abspath); extra_read_allowed_paths.push_back(abspath); diff --git a/src/Navaids/SHPParser.cxx b/src/Navaids/SHPParser.cxx index 2d31bf237..58f597760 100644 --- a/src/Navaids/SHPParser.cxx +++ b/src/Navaids/SHPParser.cxx @@ -91,8 +91,13 @@ namespace flightgear void SHPParser::parsePolyLines(const SGPath& aPath, PolyLine::Type aTy, PolyLineList& aResult, bool aClosed) { - std::string s = aPath.local8BitStr(); +#if defined(SG_WINDOWS) + const auto ws = aPath.wstr(); + gzFile file = gzopen_w(ws.c_str(), "rb"); +#else + const auto s = aPath.utf8Str(); gzFile file = gzopen(s.c_str(), "rb"); +#endif if (!file) { throw sg_io_exception("couldn't open file:", aPath); } diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 9eb762044..e6049a613 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -172,10 +172,10 @@ void FGTileMgr::reinit() for (it = sc.begin(); it != sc.end(); ++it) { fp.push_back(it->local8BitStr()); } - _options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root().local8BitStr()); + _options->setPluginStringData("SimGear::FG_ROOT", globals->get_fg_root().utf8Str()); if (_terra_sync) { - _options->setPluginStringData("SimGear::TERRASYNC_ROOT", globals->get_terrasync_dir().local8BitStr()); + _options->setPluginStringData("SimGear::TERRASYNC_ROOT", globals->get_terrasync_dir().utf8Str()); } if (!_disableNasalHooks->getBoolValue()) diff --git a/src/Time/TimeManager.cxx b/src/Time/TimeManager.cxx index c00bab291..1f6325cb0 100644 --- a/src/Time/TimeManager.cxx +++ b/src/Time/TimeManager.cxx @@ -386,9 +386,7 @@ void TimeManager::throttleUpdateRate() // periodic time updater wrapper void TimeManager::updateLocalTime() { - SGPath zone(globals->get_fg_root()); - zone.append("Timezone"); - _impl->updateLocal(globals->get_aircraft_position(), zone.local8BitStr()); + _impl->updateLocal(globals->get_aircraft_position(), globals->get_fg_root() / "Timezone"); } void TimeManager::initTimeOffset()