Octal string to Chinese

If you submit a file with a Chinese file name in a git-managed project, the git bash terminal (windows) will see a string similar to "\344\275\240\350\257\264\346\260\224\344 \270\215\346\260\224\345\260\261\346\230\257\344\272\206", such strings are octal strings (configure "git config --global core.quotepath false ”, which can solve the Chinese display problem), if you want to try it manually, the ideas are as follows:

//八进制数转16进制,反斜杆替换成%,解码输出
$str='\344\275\240\350\257\264\346\260\224\344\270\215\346\260\224\345\260\261\346\230\257\344\272\206';
$arr=explode('\\',ltrim($str,'\\'));
$bs='';
foreach($arr as $v){
	$bs.='%'.base_convert($v,8,16);
}
echo urldecode($bs);

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325209353&siteId=291194637