Skip to content

Instantly share code, notes, and snippets.

@andor44
Created January 25, 2014 00:38
Show Gist options
  • Save andor44/8609811 to your computer and use it in GitHub Desktop.
Save andor44/8609811 to your computer and use it in GitHub Desktop.
unsafe {
let namelen = GetWindowTextLengthA(wh);
let mut namebuf : ~[u8] = std::vec::with_capacity((namelen+2) as uint);
GetWindowTextA(wh, namebuf.as_mut_ptr() as *mut i8, namelen+1);
namebuf.set_len(namelen as uint);
println!("Window: {:s}", match std::str::is_utf8(namebuf) {
true => std::str::from_utf8(namebuf),
false => "Non-UTF8 win name"}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment