Page 1 of 1

Adding characters to output of text-string

Posted: Thursday 14 April 2022 18:03
by Toulon7559
Translating the contents of the KNMI Weather-info for an application, (amongst others) I use following lua-script-line for generation of output

Code: Select all

file:write("$forecast = " .. summary1 .. ";\n") --forecast
A typical result today from that lua-script-line is

Code: Select all

$forecast = Zonnige perioden;
However, the application reading this textstring requires to see

Code: Select all

$forecast = "Zonnige perioden";
Simple question, but causing headache:
how to get those enclosing " into the string?
Have looked at lua.org, but not yet seen a suitable answer

In other words:
need to find a way to insert ASCII-character hex022 into the text-string coming from that lua-script-line.

Re: Adding characters to output of text-string

Posted: Thursday 14 April 2022 18:16
by boum
Either switch your double quotes to single quotes.
Or just escape the character:

Code: Select all

file:write("$forecast = \"" .. summary1 .. "\";\n") --forecast

Re: Adding characters to output of text-string

Posted: Thursday 14 April 2022 20:47
by Toulon7559
Thanks for the hint!