lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

In message <> you wrote:

>> Does anyone have implementations for string.format("%q", ?) in other 
>> languages - other than the implementation inside Lua itsself. 
>> I'm trying to produce some Lua code from inside PHP, and need to 
>> properly format the strings. I thought it may be something lots of 
>> people need to do, and there would be numerous bits of code, but I can't 
>> find anything.
> How should "%q" format it's parameter?

The manual says:

The q option formats a string in a form suitable to be safely read back
by the Lua interpreter: the string is written between double quotes, and
all double quotes, newlines, embedded zeros, and backslashes in the string
are correctly escaped when written.

Gavin Wraith (
Home page: