From cd94b1cb8edda0b947e920a1a45c868b254284fd Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Tue, 1 May 2018 13:55:12 -0700 Subject: [PATCH] Force textify.ps1 to read files as UTF-8. Prior to the switch from AsciiDoc to Asciidoctor we converted release_notes.html to NEWS using elinks or lynx, which in turn generated ASCII output. It was sufficient to read NEWS in PowerShell using Get-Content, which defaults to ASCII. We now use tools/html2text.py, which generates UTF-8. Switch Get-Content's encoding to match. Note that Notepad detects file encodings heuristically, and that we might want to use a BOM. Bug: 14636 Change-Id: Ibd92ef7ad642631a938bb4d75a2d83f479099032 Reviewed-on: https://code.wireshark.org/review/27240 Reviewed-by: Gerald Combs Petri-Dish: Gerald Combs Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- tools/textify.ps1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/textify.ps1 b/tools/textify.ps1 index 90b9204acd..a33b3918ee 100755 --- a/tools/textify.ps1 +++ b/tools/textify.ps1 @@ -71,7 +71,13 @@ foreach ($src_file in Get-ChildItem $SourceFiles) { $src_modtime = (Get-Item $src_file).LastWriteTime if (-not (Test-Path $dst_file) -or ((Get-Item $dst_file).LastWriteTime -lt $src_modtime)) { - $contents = Get-Content $src_file + # "Get-Content -Encoding" is undocumented in PS 2.0, but works + # here. If it doesn't work elsewhere we can use: + # $contents = [System.IO.File]::ReadAllLines($src_file, $no_bom_encoding) + $contents = Get-Content -Encoding UTF8 $src_file + # We might want to write this out with a BOM in order to improve + # the chances of Notepad's UTF-8 heuristics. + # https://blogs.msdn.microsoft.com/oldnewthing/20070417-00/?p=27223 [System.IO.File]::WriteAllLines($dst_file, $contents, $no_bom_encoding) Write-Host "Textified $src_file to $dst_file" } else {