![]() |
вывод кодировки
Здравствуйте, есть скрипт, который извлекает ссылки из txt файлов, в результате выводится текстовый файл в кодировке utf 16 le..., можно ли выводить его в кодировке utf 8 ?
Код:
Select-String 'C:\work\POSTS\random\*.txt' -Pattern "^\[url\](.+)\[/url]\[/b]"| Foreach {$_.Matches.Groups[1].Value} > 'C:\work\Scripts\Create random posts\extract links.txt' Код:
Select-String 'C:\work\POSTS\random\*.txt' -Pattern "^\[url\](.+)\[/url]\[/b]"| Foreach {$_.Matches.Groups[1].Value} > 'C:\work\Scripts\Create random posts\extract links.txt' -Encoding "UTF8" |
Код:
"fff" > "C:\temp\fff.txt" Код:
"fff" |Out-File "C:\temp\fff.txt" -Encoding utf8 |
Спасибо. Сделал так:
Код:
Select-String "C:\work\POSTS\random\*.txt" -Pattern "^\[url\](.+)\[/url]\[/b]"| Foreach {$_.Matches.Groups[1].Value} |Out-File "C:\work\Scripts\Create random posts\extract links.txt" -Encoding UTF8 Код:
memo2.Lines.LoadFromFile('C:\Work\Scripts\Create random posts\extract links.txt'); Код:
 посмотрел скрипт через блокнот и исходный файл.. они все в "utf8". |
Проще всего установить в систему Powershell 7 и выполнять скрипты через него (pwsh -file "filename.ps1"), и в кодировке использовать
Код:
-Encoding UTF8NoBOM https://stackoverflow.com/questions/...ithout-the-bom |
В общем сделал так:
Код:
Select-String "C:\work\POSTS\random\*.txt" -Pattern "^\[url\](.+)\[/url]\[/b]"| Foreach {$_.Matches.Groups[1].Value} |Out-File 'C:\work\Scripts\Create random posts\extract links1.txt' |
Время: 12:57. |
Время: 12:57.
© OSzone.net 2001-