String Literal

Summary

A sequence of characters, enclosed in quotes, for representing textual data.

Syntax

"text"
'text'
"""
text
"""
'''
text
'''

Parameters

text
The contents of the string.

Description

String literals may be enclosed either in double quotes (") or single quotes (').

Special characters can be included in a string literal by prefacing with a backslash (\, including single quotes, double quotes, and backslashes:

1
2
3
import System;
 
Console.log("She asked, \"What is there I can\'t do?\"");

For more information, see the escape sequences documentation.

Multi-line Strings

JS++ supports multi-line strings by wrapping text in triple quotes (""" or '''). For example:

1
2
3
4
5
6
7
8
9
import System;
 
string s =      """
                Four score and seven years ago
                our fathers brought forth on this continent
                a new nation, conceived in Liberty, and
                dedicated to the proposition that all
                men are created equal.
                """;

Leading whitespace will be stripped based on the whitespace and indentation of the first non-empty line.

Additionally, multi-line strings can be used for heredocs and storing large blocks of HTML/XML code.

See Also

Share

HTML | BBCode | Direct Link