How can i convert strings in files to utf-8 with power shell?
Asked
Active
Viewed 107 times
1 Answers
1
I like this unescape solution. See also How do I encode Unicode character codes in a PowerShell string literal?
[regex]::unescape('\u2603') # unicode snowman
☃
[regex]::unescape('\u0068\u006f\u006d\u0065')
home
get-content file | foreach { [regex]::unescape($_) } |
set-content file2

js2010
- 23,033
- 6
- 64
- 66
-
@js2010 I see - makes sense, re-reading the question. @kwapster: Perhaps something like the following (use with caution, because it overwrites the files - also note that the encoding may change) `Get-ChildItem C:\folder -File | ForEach-Object { [regex]::Unescape((Get-Content -Raw -LiteralPath $_.fullname)) | Set-Content -NoNewLine $_.FullName }` – mklement0 May 02 '20 at 22:47