Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开启force-utf8选项后,tb_file_init在mingw平台下的路径编码与Windows下不一致 #238

Closed
jingkaimori opened this issue Sep 24, 2023 · 9 comments

Comments

@jingkaimori
Copy link

jingkaimori commented Sep 24, 2023

描述问题

开启force-utf8选项后,tb_file_init仍然假定传入的路径以当前平台的OEM编码,而windows平台下则假定为utf8,因此同样的路径在mingw下生成乱码。

期待的结果

mingw平台的行为和windows平台一致,不输出乱码。

错误信息

tb_file_ref_t file = tb_file_init("\xe6\xb5\x8b\xe8\xaf\x95", TB_FILE_MODE_DIRECT | TB_FILE_MODE_RW | TB_FILE_MODE_CREAT | TB_FILE_MODE_TRUNC);

在mingw平台下生成文件名娴嬭瘯,在Windows下生成文件名测试

相关环境

  • xmake-repo 包 mingw@mingw-w64 8.1.0
  • Visual studio 17.7.4

其他信息

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: After turning on the force-utf8 option, the path encoding of tb_file_init under the mingw platform is inconsistent with that under Windows.

@waruqi
Copy link
Member

waruqi commented Sep 24, 2023

你调下这里,另外确认下 有没有开 xmake f --charset=y ,开了走 charset 转码,不开走的 libc 的 mbstowcs 接口,实现也不同

https://github.com/tboox/tbox/blob/master/src/tbox/libc/stdlib/mbstowcs.c

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Adjust it here and check whether you have enabled xmake f --charset=y. If enabled, charset transcoding will be enabled. If libc's mbstowcs interface is not enabled, the implementation is also different.

@jingkaimori
Copy link
Author

加上--charset=y以后,mingw没问题,但是Windows无法编译:

error: tbox.lib(charset.c.obj) : error LNK2001: 无法解析的外部符号 __imp_CharNextExA
build\windows\x64\release\demo.exe : fatal error LNK1120: 1 个无法解析的外部命令

应该缺user32

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


After adding --charset=y, mingw has no problem, but Windows cannot compile:

error: tbox.lib(charset.c.obj) : error LNK2001: Unresolved external symbol __imp_CharNextExA
build\windows\x64\release\demo.exe: fatal error LNK1120: 1 unresolved external command

The user32 library should be missing

@jingkaimori
Copy link
Author

这个是demo包的问题,用xrepo里的包应该没问题

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


This is a problem with the demo package. It should be fine if you use the package in xrepo.

@waruqi
Copy link
Member

waruqi commented Sep 25, 2023

user32 我加上了

@waruqi waruqi closed this as completed Sep 25, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


user32 I added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants