GMS 2 Getting Japanese text from a a txt file.


Following some advice I was able to read from a .txt file and get a dialogue system working with english.
if file_exists(path+file)
read = file_text_open_read(path+file);
var num = 0;
while (!file_text_eof(read))
str[num++] = file_text_read_string(read);
message[num] = ""
However, even after adding character ranges to the font, getting japanese text from a file returns □□□□□□□

Yet, if I just write something directly like this,

It displays it correctly, using the same font.
What string functions would cause the text to get messed up?


It's the way you saved the text file that got you messed up.

When you save text containing material outside the 7-bit ASCII range, make sure you set the encoding to UTF-8. That's the safe bet for most European languages aside from English, and your only safe bet for non-Latin scripts. On Notepad this is configured on the Save window. On others like Atom, Notepad++ or Sublime, you will see a dedicated menu for this.

In whatever form this functionality takes, what it does is adding a short header to the file signalling that it contains UTF-8 content, with the bytes 0xEF, 0xBB, 0xBF in order. This is called the byte-order marker, or BOM for short. It tells compliant readers (the GMS file_text_*() function set is one of them) that UTF-8 tricks are employed ahead and the bytes that go above 0x7F are not to be taken alone. Failing this would give you the nonsense characters that crop up when bytes containing UTF-8 tricks are taken at an isolated face value instead of in combination with adjacent bytes.