Skip to content

Commit

Permalink
Codepage enum
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed May 13, 2021
1 parent a631715 commit 6e7d02d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Binary file modified crates/gen/default/Windows.Win32.winmd
Binary file not shown.
11 changes: 4 additions & 7 deletions examples/dxc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bindings::Windows::Win32::{
Globalization::CP_UTF8,
Globalization::*,
Graphics::Hlsl::*,
System::{
Diagnostics::Debug::ERROR_FILE_NOT_FOUND,
Expand All @@ -11,9 +11,6 @@ use std::path::Path;
use std::rc::Rc;
use windows::*;

// Only exists in newer DXC headers
const DXC_CP_UTF8: u32 = CP_UTF8;

#[cfg(target_os = "windows")]
fn dxcompiler_lib_name() -> &'static Path {
Path::new("dxcompiler.dll")
Expand All @@ -31,10 +28,10 @@ fn dxcompiler_lib_name() -> &'static Path {

fn blob_encoding_as_str(blob: &IDxcBlobEncoding) -> &str {
let mut known: BOOL = false.into();
let mut cp = 0;
let mut cp = CODEPAGE::default();
unsafe { blob.GetEncoding(known.set_abi(), cp.set_abi()) }.unwrap();
assert!(bool::from(known));
assert_eq!(cp, DXC_CP_UTF8);
assert_eq!(cp, CP_UTF8);
unsafe {
let slice = std::slice::from_raw_parts(
blob.GetBufferPointer() as *const u8,
Expand All @@ -50,7 +47,7 @@ fn create_blob(library: &IDxcLibrary, data: &str) -> windows::Result<IDxcBlobEnc
library.CreateBlobWithEncodingFromPinned(
data.as_ptr() as *const _,
data.len() as u32,
DXC_CP_UTF8,
CP_UTF8,
&mut blob,
)
}
Expand Down

0 comments on commit 6e7d02d

Please sign in to comment.