Difference between revisions of "'"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "{{'}} <div style="float:right; margin: 0 25px 20px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">'</div> In ...")
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{'}}
 
{{'}}
  
<div style="float:right; margin: 0 25px 20px 0; padding:40px; font-size:500%; font-family: Georgia; background-color: #f9f9f9; border: 2px solid #777777;">'</div>
+
The typewriter’s single quote <syntaxhighlight lang="pascal" inline>'</syntaxhighlight> is used in [[Pascal]] to delimit [[Character and string types|string and character literals]].
In [[ASCII]], the character code decimal <syntaxhighlight lang="pascal" enclose="none">39</syntaxhighlight> (or [[Hexadecimal|hexadecimal]] <syntaxhighlight lang="pascal" enclose="none">27</syntaxhighlight>) is defined to be <syntaxhighlight lang="pascal" enclose="none">'</syntaxhighlight> ( Single quotation mark ).
 
  
In [[Pascal]] programming language, the [[String|strings]] are enclosed in single quotation marks.
+
<syntaxhighlight lang="pascal" highlight="3">
 +
program helloWorld(input, output, stdErr);
 +
resourcestring
 +
greeting = 'Hello world!';
 +
begin
 +
writeLn(greeting);
 +
end.
 +
</syntaxhighlight>
  
<syntaxhighlight>
+
In order to insert a <syntaxhighlight lang="pascal" inline>'</syntaxhighlight> into a character or string literal, two <syntaxhighlight lang="pascal" inline>'</syntaxhighlight> are written back-to-back:
 +
<syntaxhighlight lang="pascal" highlight="3">
 +
program singleQuoteDemo(input, output, stdErr);
 +
begin
 +
writeLn('writeLn(''…'');');
 +
end.
 +
</syntaxhighlight>
  
program HelloWorld;
+
One may inject numeric character entities into a string, by placing them directly adjacent to one another:
var
+
<syntaxhighlight lang="pascal" highlight="3">
  s:string;
+
program bellDemo(input, output, stdErr);
 
begin
 
begin
  s := 'Hello World!';
+
writeLn('🕭'#7);
  writeLn(s);
+
end.
  readln;
+
</syntaxhighlight>
end.
 
  
</syntaxhighlight>
+
== other remarks ==
 +
The only forbidden character in a string or character literal is a [[Carriage return|carriage return]].
 +
See [https://bugs.freepascal.org/view.php?id=35827 bug #35827] for a (as of 2019‑08‑24) proposed feature.
  
If you want to print a single quotation mark in a string, it will double.
+
In [[GNU Pascal|GPC]] <syntaxhighlight lang="pascal" inline>"</syntaxhighlight> are used as string delimiters, too.
 +
Such strings can contain backslash-escaped control characters.
  
<syntaxhighlight>
+
In [[ASCII]] the character <syntaxhighlight lang="pascal" inline>'</syntaxhighlight> has the ordinal value <syntaxhighlight lang="pascal" inline>39</syntaxhighlight> (or [[Hexadecimal|hexadecimal]] <syntaxhighlight lang="pascal" inline>27</syntaxhighlight>).
  
Writeln ('ab''cd');  // string containing a single quote
+
The <syntaxhighlight lang="pascal" inline>’</syntaxhighlight> (<syntaxhighlight lang="text" inline>U+2019</syntaxhighlight> “right single quotation mark”) is the typographically correct character marking the possessive case in English (e. g. “the dog’s ball”).
  
</syntaxhighlight>
+
== see also ==
The above line is print:
+
* [https://www.freepascal.org/docs-html/ref/refse8.html § “character strings” in the ''Free Pascal reference guide'']
  abcd
 
  
 
{{Symbols}}
 
{{Symbols}}

Latest revision as of 16:15, 6 August 2022

English (en) suomi (fi)

The typewriter’s single quote ' is used in Pascal to delimit string and character literals.

program helloWorld(input, output, stdErr);
resourcestring
	greeting = 'Hello world!';
begin
	writeLn(greeting);
end.

In order to insert a ' into a character or string literal, two ' are written back-to-back:

program singleQuoteDemo(input, output, stdErr);
begin
	writeLn('writeLn('''');');
end.

One may inject numeric character entities into a string, by placing them directly adjacent to one another:

program bellDemo(input, output, stdErr);
begin
	writeLn('🕭'#7);
end.

other remarks

The only forbidden character in a string or character literal is a carriage return. See bug #35827 for a (as of 2019‑08‑24) proposed feature.

In GPC " are used as string delimiters, too. Such strings can contain backslash-escaped control characters.

In ASCII the character ' has the ordinal value 39 (or hexadecimal 27).

The (U+2019 “right single quotation mark”) is the typographically correct character marking the possessive case in English (e. g. “the dog’s ball”).

see also


navigation bar: topic: Pascal symbols
single characters

+ (plus)  •  - (minus)  •  * (asterisk)  •  / (slash)
= (equal)  •  > (greater than)  •  < (less than)
. (period)  •  : (colon)  •  ; (semi colon)
^ (hat)  •  @ (at)
$ (dollar sign)  •  & (ampersand)  •  # (hash)
' (single quote)

character pairs

<> (not equal)  •  <= (less than or equal)  •  := (becomes)  •  >= (greater than or equal)

 •  >< (symmetric difference)  •  // (double slash)