[Resolved] How to display parentheses in text?

Using display.newRetinaText, I’m trying to display some text that has parentheses in it. For example, the text: My name is “Ted”. How do I do this?

local sampletext = display.newRetinaText( “My name is “Ted”.”, 0, 0, “HelveticaNeue-CondensedBold”, 20) [import]uid: 76002 topic_id: 32326 reply_id: 332326[/import]

First, you should not be using newRetinaText. This has been deprecated and you should use newText() instead. It supports retina devices as well as supports text wrapping.

Now I think you meant to ask, how do I display text that has quote marks " instead of parentheses ().

There are two ways:

  1. Use single quotes (tick marks or apostrophes)… instead of double quotes.
    local sampletext = display.newRetinaText( ‘My name is “Ted”’.", 0, 0, “HelveticaNeue-CondensedBold”, 20)

  2. or use Lua’s special multi-line string delimiters: [[and]]
    local sampletext = display.newRetinaText( [[My name is “Ted”]].", 0, 0, “HelveticaNeue-CondensedBold”, 20)

The double square brackets can be used anywhere you would normally use either single or double quotes. If you wanted a string that uses both singles and doubles like:

[[Ted’s name is “Ted”]]

then the double square brackets will allow you to use both of the text quotes in the string.
[import]uid: 19626 topic_id: 32326 reply_id: 128675[/import]

@natelipscomb,

You can use backslashes too

"My name is \"Ted\".",
but I really like robmiracle’s second example:

[[Ted's name is "Ted"]].
I learned something new. Awesome. [import]uid: 110228 topic_id: 32326 reply_id: 128681[/import]

Thanks, Rob. They second example is perfect. [import]uid: 76002 topic_id: 32326 reply_id: 128682[/import]

First, you should not be using newRetinaText. This has been deprecated and you should use newText() instead. It supports retina devices as well as supports text wrapping.

Now I think you meant to ask, how do I display text that has quote marks " instead of parentheses ().

There are two ways:

  1. Use single quotes (tick marks or apostrophes)… instead of double quotes.
    local sampletext = display.newRetinaText( ‘My name is “Ted”’.", 0, 0, “HelveticaNeue-CondensedBold”, 20)

  2. or use Lua’s special multi-line string delimiters: [[and]]
    local sampletext = display.newRetinaText( [[My name is “Ted”]].", 0, 0, “HelveticaNeue-CondensedBold”, 20)

The double square brackets can be used anywhere you would normally use either single or double quotes. If you wanted a string that uses both singles and doubles like:

[[Ted’s name is “Ted”]]

then the double square brackets will allow you to use both of the text quotes in the string.
[import]uid: 19626 topic_id: 32326 reply_id: 128675[/import]

@natelipscomb,

You can use backslashes too

"My name is \"Ted\".",
but I really like robmiracle’s second example:

[[Ted's name is "Ted"]].
I learned something new. Awesome. [import]uid: 110228 topic_id: 32326 reply_id: 128681[/import]

Thanks, Rob. They second example is perfect. [import]uid: 76002 topic_id: 32326 reply_id: 128682[/import]