Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

コンソールに2バイト文字を出力すると文字化けする #709

Open
SorabaneSAI opened this issue Nov 12, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@SorabaneSAI
Copy link

Describe the bug/概要

こんにちは。Altseed2を利用させていただいております。
本日は日本語をログ出力した際に文字化けしたのですが、バグかもしれないのでお尋ねしたいと思いました。
普通にコンソール出力する際は文字化けしませんでした。
調査していただけると幸いです。

Environment/環境

  • OS: Windows10 Home 2004
  • Graphics: GeForce GTX 960
  • Altseed2 version: 2.1.0

コード

using Altseed2;
using System;

namespace Altseed2Tutorial
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            // エンジンを初期化
            var config = new Configuration();
            config.ConsoleLoggingEnabled = true;
            config.FileLoggingEnabled = true;
            config.LogFileName = "Log.txt";
            Engine.Initialize("Tutorial", 960, 720, config);

            // メインループ
            while (Engine.DoEvents())
            {
                // エンジンを更新
                Engine.Update();

                if (Engine.Keyboard.GetKeyState(Key.Escape) == ButtonState.Push)
                {
                    Engine.Log.Write(LogCategory.Engine, LogLevel.Critical, "テスト");
                    Engine.Log.Write(LogCategory.User, LogLevel.Error, "test2");
                    Console.WriteLine("テスト3");
                }
            }

            // エンジンの終了処理を行う
            Engine.Terminate();
        }



    }
}

実行結果

[2021-11-12 22:19:39.460] [Engine] [critical] 繝・せ繝・
[2021-11-12 22:19:39.464] [User] [error] test2
テスト3

@SorabaneSAI SorabaneSAI added the bug Something isn't working label Nov 12, 2021
@durswd
Copy link
Collaborator

durswd commented Nov 13, 2021

おそらくではありますが、コンソールの文字コードがshift-jsで、Altseed2の文字コードがutf-16であることに起因していると思われます。Windows Terminal等の新しい世代のものだったら正しく動く可能性があります。厄介な問題ではあるので、修正しない可能性もあります。

@SorabaneSAI
Copy link
Author

回答ありがとうございます。
ログのファイル出力機能も、ゲームを終了しないと出力がファイルに反映されないみたいなので、
自分で実装しようと思います。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants