本帖最后由 smss 于 2019-5-22 21:09 编辑
回复 22# WHY
现在才空下来测试
中文全部乱码无法用 建议使用昨天那个加入判断和筛选 即可- $global:n = 65; $h = @{};
- $s = [IO.File]::ReadAllText('manifest.txt', [Text.Encoding]::Default);
- $s = [regex]::Replace($s, '(?<=\bname=")[^"]+(?=")',{param($m);$a=$m.Value; if(!$h.ContainsKey($a)){$h[$a]=[char]($global:n++)}; $h[$a]});
- $s = [regex]::Replace($s, '(?<=")[^@#]*[@#][^"]+(?=")',{param($m);$a=$m.Value;forEach($k In $h.Keys){$a=$a.Replace('@'+$k,'@'+$h[$k]).Replace('#'+$k,'#'+$h[$k])};$a});
- [IO.File]::WriteAllText('manifest.xml', $s, [Text.Encoding]::UTF8);
复制代码 这个含中文不乱码 XML中含有数组的代码被替换后无法工作 |