String Literal - Bracketed Delimiters

Bracketed Delimiters

Most modern programming languages use bracket delimiters (also balanced delimiters, or quoting) to specify string literals. Double quotations are the most common quoting delimiters used:

"Hi There!"

Some languages also allow the use of single quotations as an alternative to double quotations (though the string must begin and end with the same kind of quotation mark):

'Hi There!'

Note that these quotation marks are unpaired (the same character is used as an opener and a closer), which is a hangover from the typewriter technology which was the precursor of the earliest computer input and output devices. The Unicode character set includes paired (separate opening and closing) versions of both single and double quotations, used in text, mostly in other languages than English:

“Hi There!” ‘Hi There!’ „Hi There!“ « Hi There! »

The paired double quotations can be used in Visual Basic .NET, but many other programming languages will not accept them. Unpaired marks are preferred for compatibility - many web browsers, text editors, and other tools will not correctly display unicode paired quotes, and so even in languages where they are permitted, many projects forbid their use for source code.

The PostScript programming language uses parentheses, with embedded newlines allowed, and also embedded unescaped parentheses provided they are properly paired:

(The quick (brown fox))

Similarly, the Tcl programming language uses braces (embedded newlines allowed, embedded unescaped braces allowed provided properly paired):

{The quick {brown fox}}

On one hand, this practice is derived from the single quotations in Unix shells (these are raw strings) and, on the other, from the use of braces in C for compound statements, since blocks of code is in Tcl syntactically the same thing as string literals. That the delimiters are paired is essential for making this feasible.

Read more about this topic:  String Literal