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

PCSTR.ToString() should convert as an ASCII string #761

Closed
harborsiem opened this issue Nov 11, 2022 · 1 comment · Fixed by #764
Closed

PCSTR.ToString() should convert as an ASCII string #761

harborsiem opened this issue Nov 11, 2022 · 1 comment · Fixed by #764
Assignees
Labels
bug Something isn't working

Comments

@harborsiem
Copy link

Actual behavior

PCSTR seems to have a wrong Encoding.
See Data-types

Expected behavior

Either documentation or implementation is wrong.

Repro steps

  1. NativeMethods.txt content:
PSTR
PCSTR
  1. NativeMethods.json content (if present):
  1. Any of your own code that should be shared?

Context

  • CsWin32 version: [0.2.110-beta]
  • Win32Metadata version (if explicitly set by project):
  • Target Framework: [net6.0-windows]
  • LangVersion (if explicitly set by project): [e.g. 9]
@harborsiem harborsiem added the bug Something isn't working label Nov 11, 2022
@AArnott
Copy link
Member

AArnott commented Nov 11, 2022

Are you saying that it should use ANSI instead of UTF8 when decoding the bytes?
I think wikipedia describes the situation well. In the docs, ANSI isn't a particular character set. If we were to be strict about it, I think the correct encoding to use would be whatever the current codepage is for Windows (as returned from the GetACP function).

A great resource for learning about this is here: https://learn.microsoft.com/en-us/windows/win32/intl/code-pages

In practice, I think many narrow character functions actually assume a UTF-8 encoding, but I'm not sure.

@mikebattista, thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants