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

Provide original encoding for string constants #2101

Merged
merged 5 commits into from Oct 18, 2022
Merged

Conversation

kennykerr
Copy link
Collaborator

Now that the win32 metadata captures original string encoding (microsoft/win32metadata#1008), we can use the s! and w! macros to provide those string constants in their original encoding. This makes many string constants directly and efficiently usable as constants to pass to various Windows APIs that expect either Ansi or Wide null-terminated string literals. For example, you can now call the BCrypt APIs with the various string constants directly:

let mut rng = Default::default();
BCryptOpenAlgorithmProvider(&mut rng, BCRYPT_RNG_ALGORITHM, None, Default::default())?;

I have also taken the liberty to separate the w! macro for wide string literals from WinRT support and now provide a dedicated h! macro for compile-time HSTRING support. This simplifies the vast majority of wide string literals that don't need WinRT support.

@kennykerr kennykerr changed the title Add string encodings for string constants Provide original encoding for string constants Oct 17, 2022
@kennykerr kennykerr merged commit cc2032e into master Oct 18, 2022
@kennykerr kennykerr deleted the string-encoding branch October 18, 2022 11:50
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

Successfully merging this pull request may close these issues.

None yet

1 participant