LoginSignup
1
1

Godot(C#)で"Unicode parsing error"が出るとき

Posted at

結論

おそらく君はVisualStudioを使っている。
そしてうっかり非ASCII文字である日本語をソースコードに含めてしまった。
VisualStudioはS-JISをデフォルトで使いやがるのでGodotに合わせてUTF-8を使うように設定する。
下記のような.editorconfigファイルを作成する。

.editorconfig
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

参考:

ただしすでに作成済みのファイルは解決されないので各ファイルについて名前をつけて保存からエンコード付き保存を使いUTF-8として保存する。
全部のファイルに行わねばならないので面倒。

現象

コメントとかで日本語を使うとバチクソ切れられるように見える。
image.png
コメントならまだしも、Printデバッグで日本語が使えないのは日本語母語話者としてはつらい。

試行錯誤の錯誤の部分

カスタムテンプレートも試したが相変わらず生成時にS-JISになってしまうようだった。
https://docs.godotengine.org/en/stable/tutorials/scripting/creating_script_templates.html

// meta-default: true
// meta-description: 日本語を使ってもエラーが出ないテンプレートなはずだった
using _BINDINGS_NAMESPACE_;
using System;
public partial class _CLASS_ : _BASE_
{
    public override void _Ready()
    {

    }

    public override void _Process(double delta)
    {

    }
}

そしてVisualStudio側のカスタムアイテムテンプレートも同じくだめだった。
VisualStudioが新たにプロジェクトに入ったファイルに対して勝手に文字コード適用でもしているのだろうか。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1