Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.query.roboql_literal

Module Contents

as_roboql_string_literal()

roboto.query.roboql_literal.as_roboql_string_literal(value)#View Source

Render value as a double-quoted RoboQL string literal.

RoboQL’s grammar admits exactly two escape sequences inside a double-quoted literal, \" and \\. There is no \n, \t, or \uXXXX form, so every other character is emitted verbatim, non-ASCII included. json.dumps is therefore not a substitute: it defaults to ensure_ascii=True, which renders non-ASCII characters as \uXXXX, a form RoboQL rejects.

No codepoint from U+0000 through U+001F, such as a tab or a newline, can be carried by a double-quoted literal. Those characters are emitted unchanged rather than escaped or stripped, so a value containing one yields a query that fails to parse.

Parameters

value str

Unquoted string to embed in a query, such as a session, topic, or file name.

Returns

str

value wrapped in double quotes, with backslashes and double quotes escaped.

Usage

as_roboql_string_literal('a"b')
# '"a\\"b"'
as_roboql_string_literal("café")
# '"café"'

Was this page helpful?