首页 > 系统服务 > 详细

powershell中汉字转换为ASCII编码

时间:2019-12-20 14:13:58      阅读:211      评论:0      收藏:0      [点我收藏+]
function asc($param) { 
$rtn = ‘‘
$list = $param -split ‘‘
foreach ($char in $list)
{
    if($char -ne ‘‘)
    {
       $rtn = $rtn + ("\u" + ("{0:x}" -f [int]([char]$char)))
    }
}
return $rtn 
}

 

$source="\u54ce\u5466\u4e0d\u9519\u54e6"
$evaluator={
param($v)
[char][int]($v.Value.replace(‘\u‘,‘0x‘))
}
[regex]::Replace($source,‘\\u[0-9-a-f]{4}‘,$evaluator)

write-host "Press any key to continue..."

read-host

 

powershell中汉字转换为ASCII编码

原文:https://www.cnblogs.com/icycore/p/12072581.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!