fix: fixed chinese path related problems v2(issues#24) #30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
本PR修复issues#24
下面是解释说明:
插件含中文路径名问题
而在本项目的加载逻辑中:
(/src/lse/PluginManager.cpp:73)
把它替换成
然后报错编码错误,问题来自:
(/src/legacy/main/PluginManager.cpp:57)
bool isPluginPackage = std::filesystem::is_directory(fileOrDirPath);直接使用了string去构造path,替换为
bool isPluginPackage = std::filesystem::is_directory(ll::string_utils::str2wstr(fileOrDirPath));问题就解决了
插件名称为中文时的问题
如果插件名称为中文,需要migratePlugin时
会出现两个错误,第一个是log api遇到了非u8字符
第二个是生成json时遇到了非u8字符
定位问题在:
(/src/lse/PluginMigration.cpp:34)
logger.info("migrating legacy plugin at {}", path.string());(/src/lse/PluginMigration.cpp:59)
.entry = pluginFileName.string(), .name = pluginFileBaseName.string(),替换为:
logger.info("migrating legacy plugin at {}", ll::string_utils::u8str2str(path.u8string()));.entry = ll::string_utils::u8str2str(pluginFileName.u8string()), .name = ll::string_utils::u8str2str(pluginFileBaseName.u8string()),除此之外这个文件下的抛出异常代码也没有正确处理编码,这里省略不诉
然后在加载插件前还有编码异常的代码:
(/src/lse/PluginManager.cpp:70)
manifest里面的成员都是装着utf8的string,path无法把string正确识别为utf8进行构造,需要改成wstr:
其它的编码问题
因为ll的架构设计,所有使用stlpath.string()的地方都是有BUG的,应该换成:ll::string_utils::u8str2str(stlpath.u8string())
此外,所有重载为path的/运算符都应该检查右边是否为纯英语,否则必须转为wstr,不过目前没在其它地方发现有这个的问题
stlpath.string()导致的问题清单
具体的修复过程就不在赘述了,请直接看文件变动
验证BUG是否修复
本地编译测试
在插件目录下创建一个中文名的插件和一个英文名的插件,同时BDS放置在英文目录下测试
migrating正常:
关闭后重启,加载正常:
然后更换到中文路径下重新实验:
migrating正常:
关闭后重启,加载正常:
Github Action编译测试
在插件目录下创建一个中文名的插件和一个英文名的插件,同时BDS放置在英文目录下测试
migrating正常:
关闭后重启,加载正常:
然后更换到中文路径下重新实验:
migrating正常:
关闭后重启,加载正常:
所有测试均通过
备注:因为xmake依赖的库被修改了,所以说我同步了develop分支的xmake.lua,否则无法完成Github Action编译测试