[xharness] Handle UTF8 text better. (#8065)

* Set UTF8 as the encoding for process output.
* Serve plain text as UTF-8 plain text from our test server.

This makes emojiis render as emojiis 😁😁😁
This commit is contained in:
Rolf Bjarne Kvinge 2020-03-09 18:40:46 +01:00 коммит произвёл GitHub
Родитель bd29f99aaa
Коммит bcefeb37b6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -76,6 +76,9 @@ namespace Xharness.Execution {
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
// Make cute emojiis show up as cute emojiis in the output instead of ugly text symbols!
process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
process.StartInfo.StandardErrorEncoding = Encoding.UTF8;
process.StartInfo.UseShellExecute = false;
if (environment_variables != null) {

Просмотреть файл

@ -1586,7 +1586,7 @@ namespace Xharness.Jenkins
response.ContentType = "image/png";
break;
default:
response.ContentType = System.Net.Mime.MediaTypeNames.Text.Plain;
response.ContentType = System.Net.Mime.MediaTypeNames.Text.Plain + ";charset=UTF-8";
break;
}
while ((read = fs.Read (buffer, 0, buffer.Length)) > 0)
@ -1880,7 +1880,7 @@ namespace Xharness.Jenkins
writer.WriteLine ("<h1>Test results</h1>");
foreach (var log in Logs)
writer.WriteLine ("<span id='x{2}' class='autorefreshable'> <a href='{0}' type='text/plain'>{1}</a></span><br />", log.FullPath.Substring (LogDirectory.Length + 1), log.Description, id_counter++);
writer.WriteLine ("<span id='x{2}' class='autorefreshable'> <a href='{0}' type='text/plain;charset=UTF-8'>{1}</a></span><br />", log.FullPath.Substring (LogDirectory.Length + 1), log.Description, id_counter++);
var headerColor = "black";
if (unfinishedTests.Any ()) {
@ -2197,6 +2197,9 @@ namespace Xharness.Jenkins
case "text/xml":
log_target = "_top";
break;
case "text/plain":
log_type += ";charset=UTF-8";
goto default;
default:
log_target = "_self";
break;