Page 1 of 1

[16.24] game.print does not print Russian text

Posted: Fri Feb 23, 2018 9:29 am
by WIZ4
Create a function:

Code: Select all

function text()
game.print("привет")
end
call the function from the console:
Screenshot_5.png
Screenshot_5.png (64.56 KiB) Viewed 2097 times
If the function contains English text, it is displayed:

Code: Select all

function text()
game.print("hello")
end
Screenshot_5.png
Screenshot_5.png (36.85 KiB) Viewed 2097 times

Re: [16.24] game.print does not print Russian text

Posted: Fri Feb 23, 2018 9:33 am
by eradicator
Works fine for me for both of these:

Code: Select all

function text()
game.print("привет")
end
commands.add_command('russian','test',text)

Code: Select all

/c game.print("привет")
Are you sure your text file is encoded in utf8?

Re: [16.24] game.print does not print Russian text

Posted: Fri Feb 23, 2018 9:53 am
by WIZ4
eradicator wrote:Works fine for me for both of these:

Code: Select all

function text()
game.print("привет")
end
commands.add_command('russian','test',text)

Code: Select all

/c game.print("привет")
Are you sure your text file is encoded in utf8?
The function was created in a file control.lua
If I create a function through the console, or write /c game.print("привет") then Russian is displayed:
Screenshot_5.png
Screenshot_5.png (175.96 KiB) Viewed 2091 times
But why the text does not appear if the function is written in control.lua?
And how to use this line?
commands.add_command('russian','test',text)

Re: [16.24] game.print does not print Russian text

Posted: Fri Feb 23, 2018 11:07 am
by eradicator
WIZ4 wrote: But why the text does not appear if the function is written in control.lua?
No clue. Post the whole control.lua?
WIZ4 wrote: And how to use this line?
commands.add_command('russian','test',text)
Simply type "/russian" into the console. It's just a quick way to call a random function.
http://lua-api.factorio.com/latest/LuaC ... essor.html

Re: [16.24] game.print does not print Russian text

Posted: Fri Feb 23, 2018 11:14 am
by Rseding91
Thanks for the report. The version of Lua we use doesn't official support UTF8 text so when it parses the file contents from disk it doesn't translate the string correctly.

When you do the same through console it's using a different method of parsing which sometimes works.

We may update the version of Lua we use in 0.17 to one that supports UTF8 but for now you just can't use direct non-ascii characters in Lua files.

Re: [16.24] game.print does not print Russian text

Posted: Fri Feb 23, 2018 3:59 pm
by eradicator
Rseding91 wrote:Thanks for the report. The version of Lua we use doesn't official support UTF8 text so when it parses the file contents from disk it doesn't translate the string correctly.

When you do the same through console it's using a different method of parsing which sometimes works.

We may update the version of Lua we use in 0.17 to one that supports UTF8 but for now you just can't use direct non-ascii characters in Lua files.
Um. But this worked just fine in control.lua

Code: Select all

function text()
game.print("привет")
end
commands.add_command('russian','test',text)
after changing the encoding to utf8-bom. And i've used some japanese charcters for debug printing since...0.15?.

Re: [16.24] game.print does not print Russian text

Posted: Fri Feb 23, 2018 5:11 pm
by posila
As eradicator implied ... if you use strings with non-ascii characters script files, the files need to be encoded in UTF8. I think BOM doesn't matter. Lua itself doesn't handle UTF8 strings, but as long as you are just passing strings around, it doesn't matter.