1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

fix Chinese encoding problem in GBK

This commit is contained in:
kdmcser
2025-04-19 13:30:31 +08:00
parent 975d9aedc9
commit ea3947df4f
3 changed files with 31 additions and 8 deletions

View File

@@ -27,6 +27,8 @@
#include "../IGameSettings.h"
#include "../CConfigHandler.h"
#include <boost/locale/encoding_utf.hpp>
VCMI_LIB_NAMESPACE_BEGIN
CMapInfo::CMapInfo()
@@ -40,13 +42,23 @@ CMapInfo::~CMapInfo()
vstd::clear_pointer(scenarioOptionsOfSave);
}
std::string CMapInfo::getFullFileURI(const ResourcePath & file) const
{
auto path = boost::filesystem::canonical(*CResourceHandler::get()->getResourceName(file));
#ifdef VCMI_WINDOWS
return boost::locale::conv::utf_to_utf<char>(path.native());
#else
return path.string();
#endif
}
void CMapInfo::mapInit(const std::string & fname)
{
fileURI = fname;
CMapService mapService;
ResourcePath resource = ResourcePath(fname, EResType::MAP);
originalFileURI = resource.getOriginalName();
fullFileURI = boost::filesystem::canonical(*CResourceHandler::get()->getResourceName(resource)).string();
fullFileURI = getFullFileURI(resource);
mapHeader = mapService.loadMapHeader(resource);
lastWrite = boost::filesystem::last_write_time(*CResourceHandler::get()->getResourceName(resource));
date = TextOperations::getFormattedDateTimeLocal(lastWrite);
@@ -62,7 +74,7 @@ void CMapInfo::saveInit(const ResourcePath & file)
lf >> *(mapHeader) >> scenarioOptionsOfSave;
fileURI = file.getName();
originalFileURI = file.getOriginalName();
fullFileURI = boost::filesystem::canonical(*CResourceHandler::get()->getResourceName(file)).string();
fullFileURI = getFullFileURI(file);
countPlayers();
lastWrite = boost::filesystem::last_write_time(*CResourceHandler::get()->getResourceName(file));
date = TextOperations::getFormattedDateTimeLocal(lastWrite);
@@ -76,7 +88,7 @@ void CMapInfo::campaignInit()
{
ResourcePath resource = ResourcePath(fileURI, EResType::CAMPAIGN);
originalFileURI = resource.getOriginalName();
fullFileURI = boost::filesystem::canonical(*CResourceHandler::get()->getResourceName(resource)).string();
fullFileURI = getFullFileURI(resource);
campaign = CampaignHandler::getHeader(fileURI);
lastWrite = boost::filesystem::last_write_time(*CResourceHandler::get()->getResourceName(resource));
date = TextOperations::getFormattedDateTimeLocal(lastWrite);