1 $chs='你好' 2 3 function converToUft8($str){ 4 5 $bs=[System.Text.Encoding]::Default.GetBytes($str); 6 7 $u8Char=[System.Text.UTF8Encoding]::UTF8.GetString($bs); 8 return $u8Char; 9 10 } 11 12 $enCode= converToUft8($chs) 13 echo $enCode
1 $chs='你好' 2 3 function converToUft8($str){ 4 5 $bs=[System.Text.Encoding]::Default.GetBytes($str); 6 7 $u8Char=[System.Text.UTF8Encoding]::UTF8.GetString($bs); 8 return $u8Char; 9 10 } 11 12 $enCode= converToUft8($chs) 13 echo $enCode