Skip to content

P/Invoke and UTF-32 #98975

Closed Answered by tannergooding
iahung2 asked this question in Q&A
Feb 27, 2024 · 3 comments · 1 reply
Discussion options

You must be logged in to vote

On Linux, wchar_t is UTF-32.

On Windows wchar_t is notably UTF-16. It's one of the places where different platforms have different definitions for basic C/C++ types.

CharSet.Unicode is UTF-16.

Yes, which matches the .NET char type. You would need to explicitly use int or uint (preferably matching the signedness of wchar_t for the underlying platform) when targeting Unix based platforms where wchar_t is 32-bits.

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@iahung2
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by iahung2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants