-
Notifications
You must be signed in to change notification settings - Fork 119
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
String constants need attribute indicating original encoding #1008
Comments
We have NativeTypeName, NativeTypedef, NativeArrayInfo, NativeInheritance, and other similar attributes, so perhaps something like this is in order? // ─── wincrypt.h
// #define CERT_PIN_RULES_CTL_FILENAME_A "pinrules.stl"
[NativeEncoding("ansi")]
public const string CERT_PIN_RULES_CTL_FILENAME_A = "pinrules.stl";
// #define CERT_PIN_RULES_CTL_FILENAME L"pinrules.stl"
[NativeEncoding("utf16")]
public const string CERT_PIN_RULES_CTL_FILENAME = "pinrules.stl";
// ─── bcrypt.h
// #define BCRYPT_DH_PARAMETERS L"DHParameters"
[NativeEncoding("utf16")]
public const string BCRYPT_DH_PARAMETERS = "DHParameters"; Or would folks prefer a |
Would need to update the ConstantsScraper to differentiate the various string types and add the attribute. |
This would be very helpful, as otherwise these strings are left in a frustrating to deal with state instead of being directly usable as is their intent |
Couple questions from looking into this:
|
That's a conditional macro used for APIs that have both an A and a W version where the W version is preferred so I suggest those are always compiled with UNICODE and thus land up as UTF16 strings.
The headers don't have attributes. They're either ansi or wide string literals so I wouldn't imagine there would be any ambiguity. |
Sounds good.
I meant in the metadata. Do we want to put an explicit attribute on every string in the metadata? Or assume utf-16 for example and only add an attribute for ansi? |
Sure, that sounds good. |
Thanks Mike, this is now plumbed through to Rust: microsoft/windows-rs#2101 |
Constants like
BCRYPT_3DES_ALGORITHM
need to indicate whether they were originally ANSI strings like"3DES"
or wide strings likeL"3DES"
because statically compiled languages need to bind them as compile time constants.The text was updated successfully, but these errors were encountered: