Skip to content

Commit

Permalink
Code Quality: Use EncoderReplacementFallback in QuickLook preview pro…
Browse files Browse the repository at this point in the history
  • Loading branch information
yaira2 authored Sep 10, 2024
1 parent 8ba4f45 commit a979edb
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using System.IO.Pipes;
using System.Security.Principal;
using System.Text;

namespace Files.App.Services.PreviewPopupProviders
{
Expand All @@ -30,13 +31,14 @@ public async Task SwitchPreviewAsync(string path)
private async Task DoPreviewAsync(string path, string message)
{
string pipeName = $"QuickLook.App.Pipe.{WindowsIdentity.GetCurrent().User?.Value}";
var encoding = Encoding.GetEncoding("UTF-8", new EncoderReplacementFallback("?"), new DecoderExceptionFallback());

await using var client = new NamedPipeClientStream(".", pipeName, PipeDirection.Out);
try
{
await client.ConnectAsync(TIMEOUT);

await using var writer = new StreamWriter(client);
await using var writer = new StreamWriter(client, encoding);
await writer.WriteLineAsync($"{message}|{path}");
await writer.FlushAsync();
}
Expand Down

0 comments on commit a979edb

Please sign in to comment.