Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

已存在的字符串封装传送问题 #2

Open
hzexe opened this issue Feb 21, 2019 · 1 comment
Open

已存在的字符串封装传送问题 #2

hzexe opened this issue Feb 21, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@hzexe
Copy link
Owner

hzexe commented Feb 21, 2019

在托管和非托管之间的字符串封装传送过程中,.net只支持unicode(16 bit)和ANSI,再加上c/c++中宽字符在跨平台时的种种问题,总之,有点复杂
当前的库是使用unicode封装传送字符串,然而在c/c++中wchar_t在不同平台长度不同,虽然在gcc可以通过-fshort-wchar把wchar_t视为16位,然而,它会污染其它的代码或库;
当前尝试使用

#ifdef WIN32
#define t_wchar_t wchar_t
#else
#define t_wchar_t short
#endif`

来解决,但带来的问题是非windows下输出t_wchar_t时需要做转换

放弃ANSI编码的原因是这玩意在不同语种之间不兼容,特别是一些歌手和歌名是各种语言拼写的,遇到这类与计算机语言不同的歌名或歌手必定乱码

@hzexe hzexe added the wontfix This will not be worked on label Feb 21, 2019
@hzexe hzexe pinned this issue Feb 21, 2019
@hzexe
Copy link
Owner Author

hzexe commented Feb 21, 2019

花了好长时间尝试去解决,终于找到dotnet/corefx#29968
在.net core 3.0已添加UnmanagedType.LPUTF8Str的支持

@hzexe hzexe added enhancement New feature or request and removed wontfix This will not be worked on labels Feb 21, 2019
@hzexe hzexe unpinned this issue Feb 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant