Skip to content

👾 Open Computer Use – Open-Source Alternative to Codex Computer Use

Fix UTF-8 encoding for non-ASCII characters in Windows MCP output

kogekiplay3a4c85989b24
diff --git a/apps/OpenComputerUseWindows/main.go b/apps/OpenComputerUseWindows/main.go
index 7259e93..c4d8866 100644
--- a/apps/OpenComputerUseWindows/main.go
+++ b/apps/OpenComputerUseWindows/main.go
@@ -458,7 +458,7 @@ func runPowerShell(request psRequest) (*psResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
- cmd := exec.CommandContext(ctx, "powershell.exe", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-File", scriptPath, operationPath)
+ cmd := exec.CommandContext(ctx, "powershell.exe", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-OutputEncoding", "UTF8", "-File", scriptPath, operationPath)
output, err := cmd.CombinedOutput()
if ctx.Err() == context.DeadlineExceeded {
return nil, errors.New("Windows runtime timed out after 30s")
diff --git a/apps/OpenComputerUseWindows/main_test.go b/apps/OpenComputerUseWindows/main_test.go
index 1406fd2..4f2d622 100644
--- a/apps/OpenComputerUseWindows/main_test.go
+++ b/apps/OpenComputerUseWindows/main_test.go
@@ -104,3 +104,13 @@ func TestWindowsRuntimeForegroundActionsRequireOptIn(t *testing.T) {
t.Fatal("MCP instructions must document the Windows background-focus policy")
}
}
+
+func TestUTF8EncodingInPowerShellScript(t *testing.T) {
+ // Verify that the PowerShell script sets UTF-8 encoding
+ if !strings.Contains(windowsRuntimeScript, "$OutputEncoding = [System.Text.Encoding]::UTF8") {
+ t.Fatal("PowerShell script must set $OutputEncoding to UTF-8 for proper non-ASCII character handling")
+ }
+ if !strings.Contains(windowsRuntimeScript, "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8") {
+ t.Fatal("PowerShell script must set [Console]::OutputEncoding to UTF-8 for proper non-ASCII character handling")
+ }
+}
diff --git a/apps/OpenComputerUseWindows/runtime.ps1 b/apps/OpenComputerUseWindows/runtime.ps1
index 95dcfd7..0ca3ba7 100644
--- a/apps/OpenComputerUseWindows/runtime.ps1
+++ b/apps/OpenComputerUseWindows/runtime.ps1
@@ -5,6 +5,10 @@ param(
$ErrorActionPreference = "Stop"
+# Set output encoding to UTF-8 to properly handle non-ASCII characters
+$OutputEncoding = [System.Text.Encoding]::UTF8
+[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
+
Add-Type -AssemblyName UIAutomationClient
Add-Type -AssemblyName UIAutomationTypes
Add-Type -AssemblyName System.Drawing