// Single-character char and ansichar (in the current version (2007), they are the same thing, only 1 byte) var C: Char; {the value range of the char type is: #0 .. #255, in hexadecimal format: #$0 .. # $ ff} begin {value assignment in decimal format:} C: = #65; showmessage (c); {A} {value assignment in hexadecimal format:} C: =#$ 41; showmessage (c); {A} {use the CHR function to replace # symbol} C: = CHR (65); showmessage (c); {A} C: = CHR ($41); showmessage (c); {A} {char length will certainly be 1} showmessage (inttostr (length (c ))); {1} {char, ansichar allow this convenient assignment (that is, it is compatible with a 1-byte string):} C: = 'B'; showmessage (C ); {B} end;
// Unicode Character widechar; different from ansichar, widechar occupies 2 bytes. vaR C: widechar; {value range of widechar is: #0 .. #65535, in hexadecimal format: #$0 .. # $ FFFF} begin {widechar is compatible with #0 of ansichar .. #255; but occupies 2 bytes} C: = #65; showmessage (c); {A} showmessage (inttostr (length (c); {1; this is the character length} showmessage (inttostr (sizeof (c); {2; but occupies 2 bytes} {returns a hexadecimal value} c :=# $4e07; showmessage (c); {tens of thousands} showmessage (inttostr (length (c); {1; this is the character length} showmessage (inttostr (sizeof (c); {2; but occupies 2 bytes} {with a decimal value} C: = #19975; showmessage (C ); {tens of thousands} {if it does not exceed the #255 range, you can directly assign values} C: = 'B'; showmessage (c); {tens of thousands} {This does not work}/C: = 'wan'; {This is a problem with Delphi support. It is estimated that Delphi 2008 can solve it} {This Is A work und:} C: = widestring ('wan') [1]; showmessage (c); {19975} {display my name using widechar} showmessage (#19968 #19975); {In case} showmessage (#19968 + ); {In case} showmessage (# $4e07 # $4e00); {In case} end;
// Character pointers: pchar and pansichar. In the current version (2007), there is no difference between them. vaR P: pchar; STR: string; begin {You can directly assign a String constant to pchar} p: = 'case'; showmessage (P ); {In case} showmessage (inttostr (length (p); {4} {convert the variable value} STR: = 'in case of Delphi blog'; P: = pchar (STR); {conversion} showmessage (p); {in case of Delphi blog} showmessage (inttostr (length (p); {18} end;
// Wide character pointer pwidecharvar P: pwidechar; STR: widestring; {Note that this is not string} begin {You can directly assign a String constant to pwidechar} p: = 'case '; showmessage (p); {In case} showmessage (inttostr (length (p); {2} {convert the variable value} STR: = 'delphi blog in case '; p: = pwidechar (STR); {conversion} showmessage (p); {in case of Delphi blog} showmessage (inttostr (length (p); {13} end;
Alas ~ :CodeThe coloring problem occurs again here, but now I am not in the mood to modify it. Let's talk about it later.