Difference between revisions of "Character and string types/de"
m (translation) |
(translation) |
||
Line 14: | Line 14: | ||
==== Referenz ==== | ==== Referenz ==== | ||
* [[doc:ref/refsu7.html|FPC AnsiChar documentation]] | * [[doc:ref/refsu7.html|FPC AnsiChar documentation]] | ||
+ | * [[Char/de|Verwendung Char]] | ||
== WideChar == | == WideChar == | ||
Line 25: | Line 26: | ||
|} | |} | ||
− | ==== | + | ==== Referenz ==== |
* [[doc:ref/refsu8.html|FPC WideChar documentation]] | * [[doc:ref/refsu8.html|FPC WideChar documentation]] | ||
* [http://de.wikipedia.org/wiki/UTF-16 Wikipedia UTF-16] | * [http://de.wikipedia.org/wiki/UTF-16 Wikipedia UTF-16] | ||
Line 79: | Line 80: | ||
== PChar == | == PChar == | ||
− | Eine Variable vom Typ '''PChar''' ist im Grunde ein Zeiger auf einen [[ | + | Eine Variable vom Typ '''PChar''' ist im Grunde ein Zeiger auf einen [[#AnsiChar|Char]] und ermöglicht so zusätzliche Operationen. PChars können verwendet werden, um auf [http://de.wikipedia.org/wiki/Zeichenkette#Repr.C3.A4sentation_mit_Abschlusszeichen C-Null-terminierte Zeichenfolgen], z. B. in der Interaktion mit bestimmten OS Bibliotheken oder Software von Drittanbietern zugreifen. |
{| class="wikitable" style="text-align:center; width:100px" | {| class="wikitable" style="text-align:center; width:100px" | ||
Line 88: | Line 89: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
− | * [ | + | * [http://www.freepascal.org/docs-html/ref/refsu16.html FPC PChar documentation] |
== PWideChar == | == PWideChar == | ||
− | + | Eine Variable vom Typ '''PWideChar''' ist ein Zeiger auf eine [[#WideChar|WideChar]] Variable. | |
− | |||
− | |||
{| class="wikitable" style="text-align:center; width:200px" | {| class="wikitable" style="text-align:center; width:200px" | ||
Line 104: | Line 103: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
* [[doc:rtl/system/pwidechar.html|RTL PWideChar documentation]] | * [[doc:rtl/system/pwidechar.html|RTL PWideChar documentation]] | ||
+ | * [[doc:rtl/sysutils/pcharfunctions.html|PChar related functions]] | ||
== String == | == String == | ||
− | + | Der Typ '''String''' steht für '''[[#ShortString|ShortString]]''' oder '''[[#AnsiString|AnsiString]]''', je nach [http://www.freepascal.org/docs-html/prog/progsu25.html#x32-310001.2.25 Compiler Switch {$H}]. Wenn der Schalter aus ist ({$H-}), wird bei jeder Deklaration eines Strings ein '''ShortString''' definiert. Dieser hat eine Größe von 255 Zeichen, soweit nicht anders angegeben. Wenn mit ({$H+}) ein '''String''' ohne Längenangabe deklariert wird, wird ein '''AnsiString''' erstellt, andernfalls, mit einer angegebenen Länge, ein '''ShortString'''. | |
− | ==== | + | ====Referenz==== |
− | [[String]] | + | * [[String/de|String]] |
− | [[doc:rtl/sysutils/stringfunctions.html|String functions]] | + | * [[doc:rtl/sysutils/stringfunctions.html|String functions]] |
− | [[doc:rtl/strutils/index-5.html|Reference for unit 'strutils': Procedures and functions]] | + | * [[doc:rtl/strutils/index-5.html|Reference for unit 'strutils': Procedures and functions]] |
== ShortString == | == ShortString == | ||
− | + | ShortStrings (kurze Zeichenketten) haben eine maximale Länge von 255 Zeichen mit der impliziten [[FPC Unicode Unterstützung #Codepages|codepage]] CP_ACP. Die Länge des ShortStrings wird in das erste (nicht sichtbare) Zeichen (Index 0) gespeichert. | |
{| class="wikitable" style="text-align:center; width:100px" | {| class="wikitable" style="text-align:center; width:100px" | ||
Line 125: | Line 125: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
* [http://www.freepascal.org/docs-html/ref/refsu11.html FPC ShortString documentation] | * [http://www.freepascal.org/docs-html/ref/refsu11.html FPC ShortString documentation] | ||
+ | * [[Shortstring/de|Verwendung ShortString]] | ||
== AnsiString == | == AnsiString == | ||
+ | |||
+ | '''in Bearbeitung - --[[User:Michl|Michl]] 12:40, 5 June 2014 (CEST)''' | ||
Ansistrings or UTF8Strings are strings that have no length limit. They are reference counted and are guaranteed to be null terminated. Internally, a variable of type '''AnsiString''' is treated as a pointer: the actual content of the string is stored on the heap, as much memory as needed to store the string content is allocated. | Ansistrings or UTF8Strings are strings that have no length limit. They are reference counted and are guaranteed to be null terminated. Internally, a variable of type '''AnsiString''' is treated as a pointer: the actual content of the string is stored on the heap, as much memory as needed to store the string content is allocated. | ||
Line 139: | Line 142: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
− | * [ | + | * [[doc:ref/refsu12.html|FPC AnsiString documentation]] |
+ | * [[Ansistring/de|Verwendung AnsiString]] | ||
== UnicodeString == | == UnicodeString == | ||
Line 155: | Line 159: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
* [http://www.freepascal.org/docs-html/ref/refsu13.html FPC UnicodeString documentation] | * [http://www.freepascal.org/docs-html/ref/refsu13.html FPC UnicodeString documentation] | ||
Line 162: | Line 166: | ||
Currently, the type '''UTF8String''' is an alias to the type '''[[#AnsiString|AnsiString]]'''. It is meant to contain UTF8 encoded strings (i.e. unicode data ranging from 1..4 bytes per character) UTF8String is the default string in Lazarus and LCL. | Currently, the type '''UTF8String''' is an alias to the type '''[[#AnsiString|AnsiString]]'''. It is meant to contain UTF8 encoded strings (i.e. unicode data ranging from 1..4 bytes per character) UTF8String is the default string in Lazarus and LCL. | ||
− | ==== | + | ====Referenz==== |
* [[doc:rtl/system/utf8string.html|RTL UTF8String documentation]] | * [[doc:rtl/system/utf8string.html|RTL UTF8String documentation]] | ||
Line 169: | Line 173: | ||
The type '''UTF16String''' is an alias to the type '''[[#WideString|WideString]]'''. In the LCL unit ''lclproc'' it is an alias to '''[[#UnicodeString|UnicodeString]]'''. | The type '''UTF16String''' is an alias to the type '''[[#WideString|WideString]]'''. In the LCL unit ''lclproc'' it is an alias to '''[[#UnicodeString|UnicodeString]]'''. | ||
− | ==== | + | ====Referenz==== |
* [[doc:lcl/lclproc/utf16string.html|LCL UTF16String documentation]] | * [[doc:lcl/lclproc/utf16string.html|LCL UTF16String documentation]] | ||
Line 185: | Line 189: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
* [http://www.freepascal.org/docs-html/ref/refsu14.html#x37-400003.2.8 FPC WideString documentation] | * [http://www.freepascal.org/docs-html/ref/refsu14.html#x37-400003.2.8 FPC WideString documentation] | ||
Line 199: | Line 203: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
* [[doc:rtl/system/pshortstring.html|RTL PShortString documentation]] | * [[doc:rtl/system/pshortstring.html|RTL PShortString documentation]] | ||
Line 213: | Line 217: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
* [[doc:rtl/system/pansistring.html|RTL PAnsiString documentation]] | * [[doc:rtl/system/pansistring.html|RTL PAnsiString documentation]] | ||
Line 227: | Line 231: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
* [[doc:rtl/system/punicodestring.html|RTL PUnicodeString documentation]] | * [[doc:rtl/system/punicodestring.html|RTL PUnicodeString documentation]] | ||
Line 241: | Line 245: | ||
|} | |} | ||
− | ==== | + | ====Referenz==== |
* [[doc:rtl/system/pwidestring.html|RTL PWideString documentation]] | * [[doc:rtl/system/pwidestring.html|RTL PWideString documentation]] | ||
Revision as of 12:40, 5 June 2014
│
Deutsch (de) │
English (en) │
español (es) │
français (fr) │
русский (ru) │
中文(中国大陆) (zh_CN) │
FreePascal unterstützt verschiedene Arten von Zeichen und Zeichenfolgen. Sie reichen von einzelnen ANSI-Zeichen bis hin zu Unicode-Zeichenfolgen und beinhalten auch Zeigertypen. Unterschiede gelten auch für Codierungen und Referenzzählungen.
AnsiChar
Eine Variable vom Typ AnsiChar, auch Char genannt, ist genau 1 Byte groß und enthält ein ANSI-Zeichen.
a |
Referenz
WideChar
Eine Variable vom Typ WideChar, auch als UnicodeChar bezeichnet, ist genau 2 Bytes groß und beinhaltet ein (oder ein Teil von einem) Unicode-Zeichen in UTF-16 codiert. Hinweis: Es ist nicht realisierbar alle Unicode-Codepunkte mit 2 Byte zu codieren. Es ist daher möglich, dass einzelnen Codepunkt mit 2 WideChars codiert sind.
a |
Referenz
Array of Char
Frühe Pascal-Implementierungen, die vor 1978 in Gebrauch waren, unterstützten keinen Stringtyp (mit Ausnahme von String-Konstanten). Die einzige Möglichkeit zur Speicherung einer Zeichenfolgen in einer Variablen war die Verwendung eines Array of Char. Dieser Ansatz hat viele Nachteile und wird nicht mehr empfohlen. Er wird jedoch immer noch unterstützt, um die Abwärtskompatibilität mit alten Code zu gewährleisten.
Statisches Array of Char
type
TOldString4 = array[0..3] of char;
var
aOldString4: TOldString4;
begin
aOldString4[0] := 'a';
aOldString4[1] := 'b';
aOldString4[2] := 'c';
aOldString4[3] := 'd';
end;
The statische Array of Char hat nun den Inhalt:
a | b | c | d |
Dynamisches Array of Char
var
aOldString: Array of Char;
begin
SetLength(aOldString, 5);
aOldString[0] := 'a';
aOldString[1] := 'b';
aOldString[2] := 'c';
aOldString[3] := 'd';
end;
Das dynamische Array of Char hat nun den Inhalt:
a | b | c | d | #0 |
PChar
Eine Variable vom Typ PChar ist im Grunde ein Zeiger auf einen Char und ermöglicht so zusätzliche Operationen. PChars können verwendet werden, um auf C-Null-terminierte Zeichenfolgen, z. B. in der Interaktion mit bestimmten OS Bibliotheken oder Software von Drittanbietern zugreifen.
a | b | c | #0 |
^ |
Referenz
PWideChar
Eine Variable vom Typ PWideChar ist ein Zeiger auf eine WideChar Variable.
a | b | c | #0 | #0 | |||
^ |
Referenz
String
Der Typ String steht für ShortString oder AnsiString, je nach Compiler Switch {$H}. Wenn der Schalter aus ist ({$H-}), wird bei jeder Deklaration eines Strings ein ShortString definiert. Dieser hat eine Größe von 255 Zeichen, soweit nicht anders angegeben. Wenn mit ({$H+}) ein String ohne Längenangabe deklariert wird, wird ein AnsiString erstellt, andernfalls, mit einer angegebenen Länge, ein ShortString.
Referenz
ShortString
ShortStrings (kurze Zeichenketten) haben eine maximale Länge von 255 Zeichen mit der impliziten codepage CP_ACP. Die Länge des ShortStrings wird in das erste (nicht sichtbare) Zeichen (Index 0) gespeichert.
#3 | a | b | c |
Referenz
AnsiString
in Bearbeitung - --Michl 12:40, 5 June 2014 (CEST)
Ansistrings or UTF8Strings are strings that have no length limit. They are reference counted and are guaranteed to be null terminated. Internally, a variable of type AnsiString is treated as a pointer: the actual content of the string is stored on the heap, as much memory as needed to store the string content is allocated.
a | b | c | #0 | ||||||||
RefCount | Length |
Referenz
UnicodeString
Like AnsiStrings, UnicodeStrings are reference counted, null-terminated arrays, but they are implemented as arrays of WideChars instead of regular Chars.
a | b | c | #0 | #0 | |||||||||||
RefCount | Length |
Referenz
UTF8String
Currently, the type UTF8String is an alias to the type AnsiString. It is meant to contain UTF8 encoded strings (i.e. unicode data ranging from 1..4 bytes per character) UTF8String is the default string in Lazarus and LCL.
Referenz
UTF16String
The type UTF16String is an alias to the type WideString. In the LCL unit lclproc it is an alias to UnicodeString.
Referenz
WideString
Variables of type WideString (used to represent unicode character strings in COM applications) resemble those of type UnicodeString, but unlike them they are not reference-counted. On Windows they are allocated with a special windows function which allows them to be used for OLE automation.
WideStrings consist of COM compatible UTF16 encoded bytes on Windows machines (UCS2 on Windows 2000), and they are encoded as plain UTF16 on Linux, Mac OS X and iOS.
a | b | c | #0 | #0 | |||||||
Length |
Referenz
PShortString
A variable of type PShortString is a pointer that points to the first byte of a ShortString-type variable.
#3 | a | b | c |
^ |
Referenz
PAnsiString
Variables of type PAnsiString are pointers to AnsiString-type variables. However, unlike PShortString-type variables they don't point to the first byte of the header, but to the first char of the AnsiString.
a | b | c | #0 | ||||||||
RefCount | Length | ^ |
Referenz
PUnicodeString
Variables of type PUnicodeString are pointers to variables of type UnicodeString.
a | b | c | #0 | #0 | |||||||||||
RefCount | Length | ^ |
Referenz
PWideString
Variables of type PWideString are pointers. They point to the first char of a WideString-typed variable.
a | b | c | #0 | #0 | |||||||
Length | ^ |
Referenz
See also
--Michl 13:32, 1 June 2014 (CEST)