Skip to content

Commit 3a08204

Browse files
committed
Added support for handling file paths as UTF8
1 parent 91828cc commit 3a08204

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

WindowsApp1/Compact.vb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ Public Class Compact
283283

284284
Dim DIwDString = New DirectoryInfo(wDString)
285285
directorysizeexceptionCount = 0
286-
workingDir = Chr(34) + wDString.ToString() + Chr(34)
286+
workingDir = wDString.ToString()
287287
chosenDirDisplay.Text = DIwDString.Parent.ToString + " ❯ " + DIwDString.Name.ToString
288288
uncompressedfoldersize = Math.Round(DirectorySize(DIwDString, True), 0)
289289
preSize.Text = "Uncompressed Size: " + GetOutputSize _
@@ -357,6 +357,9 @@ Public Class Compact
357357
With MyProcess.StartInfo
358358
.FileName = "CMD.exe"
359359
.Arguments = ""
360+
.StandardOutputEncoding = Encoding.UTF8 'Allow console output to use UTF-8. Otherwise it will translate to ASCII equivalents.
361+
.StandardErrorEncoding = Encoding.UTF8
362+
.WorkingDirectory = workingDir 'Set working directory via argument, allows UTF-8 to be passed directly.
360363
.UseShellExecute = False
361364
.CreateNoWindow = True
362365
.RedirectStandardInput = True
@@ -370,16 +373,8 @@ Public Class Compact
370373
MyProcess.BeginErrorReadLine()
371374
MyProcess.BeginOutputReadLine()
372375

373-
374376
Try
375-
376-
MyProcess.StandardInput.WriteLine("cd /d " + workingDir)
377-
MyProcess.StandardInput.Flush()
378-
379-
MyProcess.StandardInput.WriteLine("") 'Required for the embedded console to show the next line in the buffer after the 'cd' command. No idea why
380-
MyProcess.StandardInput.Flush()
381-
382-
MyProcess.StandardInput.WriteLine("chcp 437")
377+
MyProcess.StandardInput.WriteLine("chcp 65001") 'UTF-8 codepage in console output. Otherwise it will translate to ASCII equivalents.
383378
MyProcess.StandardInput.Flush()
384379

385380
RunCompact(passthrougharg)

0 commit comments

Comments
 (0)