Difference between revisions of "Character and string types"
Jwdietrich (talk | contribs) |
Jwdietrich (talk | contribs) |
||
Line 3: | Line 3: | ||
== AnsiChar == | == AnsiChar == | ||
− | A variable of type AnsiChar is exactly 1 byte in size, and contains one ASCII character. | + | A variable of type '''AnsiChar''' is exactly 1 byte in size, and contains one ASCII character. |
{| class="wikitable" style="text-align:center; width:25px" | {| class="wikitable" style="text-align:center; width:25px" | ||
Line 15: | Line 15: | ||
== WideChar == | == WideChar == | ||
− | A variable of type WideChar is exactly 2 bytes in size, and contains one [[LCL Unicode Support|Unicode]] character in UTF-16 encoding. | + | A variable of type '''WideChar''' is exactly 2 bytes in size, and contains one [[LCL Unicode Support|Unicode]] character in UTF-16 encoding. |
{| class="wikitable" style="text-align:center; width:50px" | {| class="wikitable" style="text-align:center; width:50px" | ||
Line 27: | Line 27: | ||
== PChar == | == PChar == | ||
− | A variable of type PChar is basically a pointer to a Char type, but allows additional operations. PChars can be used to access C-style null-terminated strings, e.g. in interaction with certain OS libraries or third-party software. | + | A variable of type '''PChar''' is basically a pointer to a Char type, but allows additional operations. PChars can be used to access C-style null-terminated strings, e.g. in interaction with certain OS libraries or third-party software. |
{| class="wikitable" style="text-align:center; width:100px" | {| class="wikitable" style="text-align:center; width:100px" | ||
Line 41: | Line 41: | ||
== PWideChar == | == PWideChar == | ||
− | A variable of type PWideChar is a pointer to a [[#WideChar|WideChar]] variable. | + | A variable of type '''PWideChar''' is a pointer to a [[#WideChar|WideChar]] variable. |
{| class="wikitable" style="text-align:center; width:200px" | {| class="wikitable" style="text-align:center; width:200px" |
Revision as of 16:28, 28 December 2013
Free Pascal supports several types of characters and strings.
AnsiChar
A variable of type AnsiChar is exactly 1 byte in size, and contains one ASCII character.
a |
Reference
WideChar
A variable of type WideChar is exactly 2 bytes in size, and contains one Unicode character in UTF-16 encoding.
a |
Reference
PChar
A variable of type PChar is basically a pointer to a Char type, but allows additional operations. PChars can be used to access C-style null-terminated strings, e.g. in interaction with certain OS libraries or third-party software.
a | b | c | #0 |
^ |
Reference
PWideChar
A variable of type PWideChar is a pointer to a WideChar variable.
a | b | c | #0 | #0 | |||
^ |
Reference
String
The type string may refer to ShortString or AnsiString, depending from the {$H} switch. If the switch is off ({$H-}) then any string declaration will define a ShortString. If it is on ({$H+}) string without length specifier will define an AnsiString, otherwise a ShortString with specified length.