[16.24] game.print does not print Russian text

Bugs that are actually features.
User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

[16.24] game.print does not print Russian text

Post 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 2091 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 2091 times
My native language is russian. Sorry if my messages are difficult to read.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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?
User avatar
WIZ4
Fast Inserter
Fast Inserter
Posts: 209
Joined: Thu Apr 07, 2016 1:36 pm
Contact:

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

Post 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 2085 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)
My native language is russian. Sorry if my messages are difficult to read.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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
Rseding91
Factorio Staff
Factorio Staff
Posts: 16102
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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?.
posila
Former Staff
Former Staff
Posts: 5448
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

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

Post 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.
Post Reply

Return to “Not a bug”