Godot C# error Invalid UTF-8 continuation byte

Godot Version

Godot_v4.3-stable_mono_win64

Question

I am a newbie in Godot, I have already visited more than 25 sites but still have not found a solution to the problem.
when changing the text via code, an error appears. However, if you set the text in godot itself, there is no error.

error: Unicode parsing error, some characters were replaced with � (U+FFFD): Invalid UTF-8 continuation byte (ef … f0 …)

I use this code:

using Godot;
using System;
using System.Text;

public partial class Main : Node
{
    private RichTextLabel _text;

    public override void _Ready()
    {
        _text = GetNode<RichTextLabel>("text");
        _text.Text = "привет";
    }

    public override void _Process(double delta)
    {
    }
}

I tried using _text.SetText(“привет”); but in this case the text didn’t change at all.

p.s. I don’t know English well so I used Google Translate.

My guess is the encoding used by your editor is set wrong, What are you using to edit the c# code?

2 Likes

yes i found the problem, you are right, i used visual studio 2022 which saved in utf-16 encoding)

1 Like

thanks but this won’t solve the problem. you just had to change the encoding when saving (I use visual studio 2022). I searched for this for 5 hours and the solution was so simple)

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.