@@ -636,23 +636,27 @@ pub fn decode_path(bytes: &[u8]) -> std::io::Result<PathBuf> {
636636
637637#[ cfg( windows) ]
638638pub fn decode_path ( bytes : & [ u8 ] ) -> std:: io:: Result < PathBuf > {
639- let codepage = winapi:: um:: winnls:: CP_OEMCP ;
640- let flags = winapi:: um:: winnls:: MB_ERR_INVALID_CHARS ;
639+ use windows_sys:: Win32 :: Globalization :: { CP_OEMCP , MB_ERR_INVALID_CHARS } ;
640+
641+ let codepage = CP_OEMCP ;
642+ let flags = MB_ERR_INVALID_CHARS ;
641643
642644 Ok ( OsString :: from_wide ( & multi_byte_to_wide_char ( codepage, flags, bytes) ?) . into ( ) )
643645}
644646
645647#[ cfg( windows) ]
646648pub fn wide_char_to_multi_byte ( wide_char_str : & [ u16 ] ) -> std:: io:: Result < Vec < u8 > > {
647- let codepage = winapi:: um:: winnls:: CP_OEMCP ;
649+ use windows_sys:: Win32 :: Globalization :: { WideCharToMultiByte , CP_OEMCP } ;
650+
651+ let codepage = CP_OEMCP ;
648652 let flags = 0 ;
649653 // Empty string
650654 if wide_char_str. is_empty ( ) {
651655 return Ok ( Vec :: new ( ) ) ;
652656 }
653657 unsafe {
654658 // Get length of multibyte string
655- let len = winapi :: um :: stringapiset :: WideCharToMultiByte (
659+ let len = WideCharToMultiByte (
656660 codepage,
657661 flags,
658662 wide_char_str. as_ptr ( ) ,
@@ -666,7 +670,7 @@ pub fn wide_char_to_multi_byte(wide_char_str: &[u16]) -> std::io::Result<Vec<u8>
666670 if len > 0 {
667671 // Convert from UTF-16 to multibyte
668672 let mut astr: Vec < u8 > = Vec :: with_capacity ( len as usize ) ;
669- let len = winapi :: um :: stringapiset :: WideCharToMultiByte (
673+ let len = WideCharToMultiByte (
670674 codepage,
671675 flags,
672676 wide_char_str. as_ptr ( ) ,
@@ -695,30 +699,32 @@ pub fn wide_char_to_multi_byte(wide_char_str: &[u16]) -> std::io::Result<Vec<u8>
695699/// See https://msdn.microsoft.com/en-us/library/windows/desktop/dd319072(v=vs.85).aspx
696700/// for more details.
697701pub fn multi_byte_to_wide_char (
698- codepage : winapi :: shared :: minwindef :: DWORD ,
699- flags : winapi :: shared :: minwindef :: DWORD ,
702+ codepage : u32 ,
703+ flags : u32 ,
700704 multi_byte_str : & [ u8 ] ,
701705) -> std:: io:: Result < Vec < u16 > > {
706+ use windows_sys:: Win32 :: Globalization :: MultiByteToWideChar ;
707+
702708 if multi_byte_str. is_empty ( ) {
703709 return Ok ( vec ! [ ] ) ;
704710 }
705711 unsafe {
706712 // Get length of UTF-16 string
707- let len = winapi :: um :: stringapiset :: MultiByteToWideChar (
713+ let len = MultiByteToWideChar (
708714 codepage,
709715 flags,
710- multi_byte_str. as_ptr ( ) as winapi :: um :: winnt :: LPSTR ,
716+ multi_byte_str. as_ptr ( ) ,
711717 multi_byte_str. len ( ) as i32 ,
712718 std:: ptr:: null_mut ( ) ,
713719 0 ,
714720 ) ;
715721 if len > 0 {
716722 // Convert to UTF-16
717723 let mut wstr: Vec < u16 > = Vec :: with_capacity ( len as usize ) ;
718- let len = winapi :: um :: stringapiset :: MultiByteToWideChar (
724+ let len = MultiByteToWideChar (
719725 codepage,
720726 flags,
721- multi_byte_str. as_ptr ( ) as winapi :: um :: winnt :: LPSTR ,
727+ multi_byte_str. as_ptr ( ) ,
722728 multi_byte_str. len ( ) as i32 ,
723729 wstr. as_mut_ptr ( ) ,
724730 len,
0 commit comments