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

C# Strings are (likely) not always UTF-8 compatible #63

Open
CryZe opened this issue Apr 16, 2018 · 1 comment
Open

C# Strings are (likely) not always UTF-8 compatible #63

CryZe opened this issue Apr 16, 2018 · 1 comment

Comments

@CryZe
Copy link

CryZe commented Apr 16, 2018

The string argument page says the following:

Native strings are automatically marshalled to C-compatible strings.

But it turns out that on Japanese Windows the strings are marshalled as Shift-JIS and not UTF-8. I'm still in the middle of figuring this bug out, but it seems like this is wrong.

@iinuwa
Copy link

iinuwa commented Sep 26, 2021

The answer to this is that if the MarshalAs attribute isn't specified for a string, the string is encoded according to the system's ANSI code page. On Linux, this is always UTF-8, but on Windows, it can vary, since it uses this function.

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

2 participants