SteveSandersonMS / dotnet-wasi-sdk

Packages for building .NET projects as standalone WASI-compliant modules
518 stars 36 forks source link

non-ASCII characters are garbled #1

Closed ufcpp closed 2 years ago

ufcpp commented 2 years ago

Version Used

Windows 11 (current culture: ja-JP) .NET SDK 7.0.100-preview.2.22153.17 Wasi.Sdk 0.1.0

Step to repro

Console.WriteLine("a α Я あ");
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Wasi.Sdk" Version="0.1.0" />
  </ItemGroup>

</Project>

Run with

Expected result

a α Я あ

Actual result

a ホア ミッ 縺・

This output seems like a string written "a α Я あ" as UTF-8 and read as Shift_JIS (code page 932). CP932 is a default encoding for Windows ja-JP.

On the other hands, if you run the wasm on WebAssembly.sh, there is no characters garbled.

image

ufcpp commented 2 years ago

Ah, chcp 650001 solves the issue.

>chcp 65001
Active code page: 65001

>wasmtime WasiSdkConsole1.wasm
a α Я あ
SteveSandersonMS commented 2 years ago

Cool, thanks for letting us know! So it looks like an issue in the terminal emulator, not in this project.