Godot Version
v4.5.1.stable.official
Question
I am receiving the following error on my Godot 4.5 project when I open it:
- ERROR: Unicode parsing error, some characters were replaced with � (U+FFFD): Unexpected NUL character
I’m fairly certain that the root cause of this error is text that I pasted into one of my GDScript files. I don’t use C# - only GDScript, FYI. I actually receive two instances of this error on start-up (see below) which would lead me to believe there are two instances in my scripts.
I tried having an LLM write me a Python script to scan through all of my GDScript files looking for invalid characters, but nothing was found. If I could find out what file and what line number is associated with the errors, I’m sure that I could replace the text and fix the issue. There are potentially hundreds of culprits, and so it’s not practical for me to manually go through and replace all the text.
Is there any way to trace these errors back to the source file and line?
If you know the files, copy and paste the files into Notepad. See if the characters become visible. Then copy and paste that back in.
Alternately, delete and replace all the indentations in your code for the offending file(s).
In the future, if you’re copying code in, also make sure that your source is using Tab indentation and not Space indentation.
The text that likely contains the invalid characters isn’t code, it’s strings of text (like dialogue). They’re contained in a GDScript dictionary so that the text can be referenced by a dictionary key. There are hundreds of entries, and visually scanning the text isn’t feasible.
I missed you were on 4.5.1. Apologies. It was late. Upgrade to Godot 4.6. One of the features added was to try and link all errors to lines in code. So doing that may turn those errors into something traceable.
2 Likes
No worries. I tried 4.6, but because the errors appear when Godot loads (and not when I run the debugger) there is no stack trace or debugger info. It’s just printed to the output panel. I don’t see a way to use 4.6’s features to trace this.
I will note that I scanned all of my offending files for invalid Unicode using PowerShell scripts. No invalid Unicode was found. I did have some umlauts and other symbols that are valid Unicode but perhaps unusual, and so I went through and deleted all of them.
The Unicode errors persist even after scanning and sanitizing all of my script files. I can’t imagine what would cause the error if it’s not my script files, and so I guess I’ll have to just move on. The error doesn’t appear to be preventing me from running my project, so I’ll ignore it unless/until there’s some way to investigate the cause.
1 Like
Just a guess, but could it be that your file is encoded as utf-16 instead of utf-8?
Holy crap, I haven’t learned in a new git command in decades. That’s awesome.
1 Like