Sign in Join
Wiki copytemporary

Character and string types/fr: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-Free Pascal supportes plusieurs **types de [[Char/fr|caractères]] et de [[String/fr|chaîne de caractères]]**. Il s'étendent du simple caractère ANSI aux chaînes Unicode et incluent aussi les types pointer. Les différence s'appliquent aussi aux encodages et au comptage de référence.
1+Free Pascal supportes plusieurs **types de[[Char/fr|caractères]] et de [[String/fr|chaîne de caractères]]**. Il s'étendent du simple caractère ANSI aux chaînes Unicode et incluent aussi les types pointer. Les différence s'appliquent aussi aux encodages et au comptage de référence.
22
3-## AnsiChar
3+## Contents
44
5-Une variable de type **AnsiChar**, aussi mentionnée comme **[[Character and string types/fr|Char]]**, a une taille d'exactement un octet et contient un caractère ANSI.
5+ * 1 AnsiChar
6+ * 1.1 Référence
7+ * 2 WideChar
8+ * 2.1 Références
9+ * 3 Tableau de Char
10+ * 3.1 Tableau de Char statique
11+ * 3.2 Tableau de Char dynamique
12+ * 4 PChar
13+ * 4.1 Référence
14+ * 5 PWideChar
15+ * 5.1 Référence
16+ * 6 String
17+ * 6.1 Référence
18+ * 7 ShortString
19+ * 7.1 Référence
20+ * 8 AnsiString
21+ * 8.1 Référence
22+ * 9 UnicodeString
23+ * 9.1 Référence
24+ * 10 UTF8String
25+ * 10.1 Référence
26+ * 11 UTF16String
27+ * 11.1 Référence
28+ * 12 WideString
29+ * 12.1 Référence
30+ * 13 PShortString
31+ * 13.1 Référence
32+ * 14 PAnsiString
33+ * 14.1 Référence
34+ * 15 PUnicodeString
35+ * 15.1 Référence
36+ * 16 PWideString
37+ * 16.1 Référence
38+ * 17 Constantes String
39+ * 18 Voir aussi
640
7-| |
8-|-----|
9-| a |
41+## AnsiChar
1042
43+Une variable de type **AnsiChar** , aussi mentionnée comme **[[Character and string types/fr|Char]]** , a une taille d'exactement un octet et contient un caractère ANSI.
44+
45+a
46+---
47+
1148#### Référence
1249
13-- [Documentation FPC sur les AnsiChar](http://www.freepascal.org/docs-html/ref/refsu7.html)
14-- [[Char/fr|Usage de Char]]
50+ * [Documentation FPC sur les AnsiChar](<http://www.freepascal.org/docs-html/ref/refsu7.html>)
51+ * [[Char/fr|Usage de Char]]
1552
1653## WideChar
1754
18-Une variable du type **WideChar**, aussi mentionnée comme**UnicodeChar**, est exactement d'une taille de 2 octets, et contient une partie des caractères [[LCL Unicode Support/fr|Unicode]] dans l'encodage UTF-16. Note : il est impossible d'encodes tous les points de code Unicode dans 2 octets. En conséquence, 2 WideChars pourraient être nécessaires pour encoder un simple point de code.
19-
20-| | |
21-|-----|-----|
22-| | a |
55+Une variable du type **WideChar** , aussi mentionnée comme**UnicodeChar** , est exactement d'une taille de 2 octets, et contient une partie des caractères [[LCL Unicode Support/fr|Unicode]] dans l'encodage UTF-16. Note : il est impossible d'encodes tous les points de code Unicode dans 2 octets. En conséquence, 2 WideChars pourraient être nécessaires pour encoder un simple point de code.
2356
57+| a
58+---|---
59+
2460#### Références
2561
26-- [Documentation FPC sur les WideChar](http://www.freepascal.org/docs-html/ref/refsu8.html)
27-- [Information sur l'UTF-16 dans Wikipedia](https://fr.wikipedia.org/wiki/UTF-16)
28-- [[doc:rtl/system/unicodechar.html|Documentation sur RTL UnicodeChar]]
62+ * [Documentation FPC sur les WideChar](<http://www.freepascal.org/docs-html/ref/refsu8.html>)
63+ * [Information sur l'UTF-16 dans Wikipedia](<https://fr.wikipedia.org/wiki/UTF-16>)
64+ * [Documentation sur RTL UnicodeChar](<http://lazarus-ccr.sourceforge.net/docs/rtl/system/unicodechar.html> "doc:rtl/system/unicodechar.html")
2965
3066## Tableau de Char
3167
32-Les premières implémentations de Pascal, utilisées avant 1978, ne supportaient pas le type chaîne (exception faite des constantes chaînes). La seule possibilité pour stocker des chaînes dans des variables consistaient à utiliser des tableaux de char. Cette approche a de nombreux inconvénients et n'est plus recommandée. C'est néanmoins toujours supporté pour assurer la compatibilité descendante avec l'ancien code.
68+Les premières implémentations de Pascal, utilisées avant 1978, ne supportaient pas le type chaîne (exception faite des constantes chaînes). La seule possibilité pour stocker des chaînes dans des variables consistaient à utiliser des tableaux de char. Cette approche a de nombreux inconvénients et n'est plus recommandée. C'est néanmoins toujours supporté pour assurer la compatibilité descendante avec l'ancien code.
3369
3470### Tableau de Char statique
35-
36-``` pascal
71+```
3772type
38- TOldString4 = array[0..3] of char;
39-var
40- aOldString4: TOldString4;
41-begin
42- aOldString4[0] := 'a';
43- aOldString4[1] := 'b';
44- aOldString4[2] := 'c';
45- aOldString4[3] := 'd';
46-end;
73+ TOldString4 = array[0..3] of char;
74+ var
75+ aOldString4: TOldString4;
76+ begin
77+ aOldString4[0] := 'a';
78+ aOldString4[1] := 'b';
79+ aOldString4[2] := 'c';
80+ aOldString4[3] := 'd';
81+ end;
4782```
4883
49-Le tableau de char statique contient dorénavant:
50-
51-| | | | |
52-|-----|-----|-----|-----|
53-| a | b | c | d |
84+Le tableau de char statique contient dorénavant:
5485
55-> **Note:** Les chars non affectés contiennent n'importe quoi, en fonction de ce qui se trouvait en mémoire quand la mémoire pour le tableau est devenue disponible (le contenu du tableau n'est pas initialisé).
86+a | b | c | d
87+---|---|---|---
88+
89+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Remarque:** Les chars non affectés contiennent n'importe quoi, en fonction de ce qui se trouvait en mémoire quand la mémoire pour le tableau est devenue disponible (le contenu du tableau n'est pas initialisé).
5690
5791### Tableau de Char dynamique
58-
59-``` pascal
92+```
6093var
61- aOldString: Array of Char; // pas de dimension!!
62-begin
63- SetLength(aOldString, 5);
64- aOldString[0] := 'a';
65- aOldString[1] := 'b';
66- aOldString[2] := 'c';
67- aOldString[3] := 'd';
68-end;
94+ aOldString: Array of Char; // pas de dimension!!
95+ begin
96+ SetLength(aOldString, 5);
97+ aOldString[0] := 'a';
98+ aOldString[1] := 'b';
99+ aOldString[2] := 'c';
100+ aOldString[3] := 'd';
101+ end;
69102```
70103
71-Le tableau de char dynamique contient dorénavant:
72-
73-| | | | | |
74-|-----|-----|-----|-----|-----|
75-| a | b | c | d | \#0 |
104+Le tableau de char dynamique contient dorénavant:
76105
77-> **Note:** Les chars non affectés dans les tableaux dynamiques contiennent des \#0, parce que les positions vides de tous les tableaux dynamiques sont dès le départ initialisées avec 0 (ou \#0, ou nil, ou ...)
106+a | b | c | d | #0
107+---|---|---|---|---
108+
109+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Remarque:** Les chars non affectés dans les tableaux dynamiques contiennent des #0, parce que les positions vides de tous les tableaux dynamiques sont dès le départ initialisées avec 0 (ou #0, ou nil, ou ...)
78110
79111## PChar
80112
81-Une variable de type **PChar** est simplement un pointeur vers un type **Char**, mais permet des opérations supplémentaires. Les PChars peuvent être utilisé pour accéder à des [chaînes C à zéro terminal](http://en.wikipedia.org/wiki/Null-terminated_string), par exemple en interaction avec certaines API systèmes ou des logiciels tierce partie.
82-
83-| | | | |
84-|-----|-----|-----|-----|
85-| a | b | c | \#0 |
86-| ^ | | | |
113+Une variable de type **PChar** est simplement un pointeur vers un type **Char** , mais permet des opérations supplémentaires. Les PChars peuvent être utilisé pour accéder à des [chaînes C à zéro terminal](<http://en.wikipedia.org/wiki/Null-terminated_string>), par exemple en interaction avec certaines API systèmes ou des logiciels tierce partie.
87114
115+a | b | c | #0
116+---|---|---|---
117+^
118+
88119#### Référence
89120
90-- [Documentation FPC sur les PChar](http://www.freepascal.org/docs-html/ref/refsu16.html)
91-- [[doc:rtl/sysutils/pcharfunctions.html|Fonctions associées à PChar]]
121+ * [Documentation FPC sur les PChar](<http://www.freepascal.org/docs-html/ref/refsu16.html>)
122+ * [Fonctions associées à PChar](<http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/pcharfunctions.html> "doc:rtl/sysutils/pcharfunctions.html")
92123
93124## PWideChar
94125
95-Une variable de type **PWideChar** est un pointeur vers une variable [[Character and string types/fr|WideChar]].
96-
97-| | | | | | | | |
98-|-----|-----|-----|-----|-----|-----|-----|-----|
99-| | a | | b | | c | \#0 | \#0 |
100-| ^ | | | | | | | |
126+Une variable de type **PWideChar** est un pointeur vers une variable [[Character and string types/fr|WideChar]].
101127
128+| a | | b | | c | #0 | #0
129+---|---|---|---|---|---|---|---
130+^
131+
102132#### Référence
103133
104-- [[doc:rtl/system/pwidechar.html|Documentation sur RTL PWideChar]]
134+ * [Documentation sur RTL PWideChar](<http://lazarus-ccr.sourceforge.net/docs/rtl/system/pwidechar.html> "doc:rtl/system/pwidechar.html")
105135
106136## String
107137
108-Le type **String** peut faire référence à **ShortString** ou **AnsiString**, selon la [bascule {\$H}](http://www.freepascal.org/docs-html/prog/progsu25.html#x32-310001.2.25). Si la bascule est off ({\$H-}) alors toute déclaration string va définir une **ShortString**. Sa taille sera de 255 caractères, si elle n'est pas spécifiée autrement. Si la bascule est on ({\$H+}) **string** sans spécifier la taille va définir une **AnsiString**, sinon une **ShortString** avec une taille spécifiée. Dans le **mode delphiunicode** **String'' est**UnicodeString'''.
138+Le type **String'_peut faire référence à_** _ShortString**ou**AnsiString**, selon la[bascule {$H}](<http://www.freepascal.org/docs-html/prog/progsu25.html#x32-310001.2.25>). Si la bascule est off ({$H-}) alors toute déclaration string va définir une **ShortString**. Sa taille sera de 255 caractères, si elle n'est pas spécifiée autrement. Si la bascule est on ({$H+})** string**sans spécifier la taille va définir une** AnsiString**, sinon une** ShortString**avec une taille spécifiée. Dans le** mode delphiunicode**** String_ est **UnicodeString**.
109139
110140#### Référence
111141
112-- [[String/fr|Usage des String]]
113-- [[doc:rtl/sysutils/stringfunctions.html|Fonctions sur les chaînes]]
114-- [[doc:rtl/strutils/index-5.html|Référence sur l'unité 'strutils': Procédures et fonctions]]
142+ * [[String/fr|Usage des String]]
143+ * [Fonctions sur les chaînes](<http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/stringfunctions.html> "doc:rtl/sysutils/stringfunctions.html")
144+ * [Référence sur l'unité 'strutils': Procédures et fonctions](<http://lazarus-ccr.sourceforge.net/docs/rtl/strutils/index-5.html> "doc:rtl/strutils/index-5.html")
115145
116146## ShortString
117147
118-Les chaînes courtes ont une taille maximale de 255 caractères avec la [[FPC Unicode support|page de code]] CP_ACP implicite. La longueur effective de la chaîne est conservée dans le caractère à l'index 0.
119-
120-| | | | |
121-|-----|-----|-----|-----|
122-| \#3 | a | b | c |
148+Les chaînes courtes ont une taille maximale de 255 caractères avec la [[FPC Unicode support|page de code]] CP_ACP implicite. La longueur effective de la chaîne est conservée dans le caractère à l'index 0.
123149
150+#3 | a | b | c
151+---|---|---|---
152+
124153#### Référence
125154
126-- [Documentation FPC sur ShortString](http://www.freepascal.org/docs-html/ref/refsu11.html#x34-370003.2.5)
155+ * [Documentation FPC sur ShortString](<http://www.freepascal.org/docs-html/ref/refsu11.html#x34-370003.2.5>)
127156
128157## AnsiString
129158
130-Les Ansistrings ou les UTF8Strings sont des chaînes qui n'ont pas de limite de taille. Le [comptage de référence](http://en.wikipedia.org/wiki/Reference_counting) s'applique à elle et il est garanti qu'elles soient à [zéro terminal](http://en.wikipedia.org/wiki/Null-terminated_string). En interne, une variable de type **AnsiString** est traitée comme un pointeur: le contenu réel de la chaîne se trouve dans le tas, la mémoire nécessaire à son contenu étant allouée.
131-
132-<table>
133-<tbody>
134-<tr>
135-<td style="width: 8%;"></td>
136-<td style="width: 8%;"></td>
137-<td style="width: 8%;"></td>
138-<td style="width: 8%;"></td>
139-<td style="width: 8%;"></td>
140-<td style="width: 8%;"></td>
141-<td style="width: 8%;"></td>
142-<td style="width: 8%;"></td>
143-<td style="width: 8%;">a</td>
144-<td style="width: 8%;">b</td>
145-<td style="width: 8%;">c</td>
146-<td style="width: 8%;">#0</td>
147-</tr>
148-<tr>
149-<td colspan="4" style="width: 16%;">RefCount</td>
150-<td colspan="4" style="width: 16%;">Length</td>
151-<td></td>
152-<td></td>
153-<td></td>
154-<td></td>
155-</tr>
156-</tbody>
157-</table>
159+Les Ansistrings ou les UTF8Strings sont des chaînes qui n'ont pas de limite de taille. Le [comptage de référence](<http://en.wikipedia.org/wiki/Reference_counting>) s'applique à elle et il est garanti qu'elles soient à [zéro terminal](<http://en.wikipedia.org/wiki/Null-terminated_string>). En interne, une variable de type **AnsiString** est traitée comme un pointeur: le contenu réel de la chaîne se trouve dans le tas, la mémoire nécessaire à son contenu étant allouée.
158160
161+| | | | | | | | a | b | c | #0
162+---|---|---|---|---|---|---|---|---|---|---|---
163+RefCount | Length
164+
159165#### Référence
160166
161-- [Documentation FPC sur les AnsiString](http://www.freepascal.org/docs-html/ref/refsu12.html)
167+ * [Documentation FPC sur les AnsiString](<http://www.freepascal.org/docs-html/ref/refsu12.html>)
162168
163169## UnicodeString
164170
165-Telles les **AnsiStrings**, **UnicodeStrings** sont sujette au comptage de référence, sont des tableau à zéro terminal, mais elles sont implémentées comme des tableaux de **WideChars** au lieu de **Chars** ordinaires.
166-
167-> **Note:** L'appelation UnicodeString est un peu ambiguë mais provient sans doute de son emploi dans Delphi sur Windows, où le système d'exploitation utilise l'encodage UTF-16 ; ce n'est pas le seul type de chaîne qui permet de contenir des données Unicode (voir aussi UTF8String)...
171+Telles les **AnsiStrings** , **UnicodeStrings** sont sujette au comptage de référence, sont des tableau à zéro terminal, mais elles sont implémentées comme des tableaux de **WideChars** au lieu de **Chars** ordinaires.
168172
169-<table>
170-<tbody>
171-<tr>
172-<td style="width: 7%;"></td>
173-<td style="width: 7%;"></td>
174-<td style="width: 7%;"></td>
175-<td style="width: 7%;"></td>
176-<td style="width: 7%;"></td>
177-<td style="width: 7%;"></td>
178-<td style="width: 7%;"></td>
179-<td style="width: 7%;"></td>
180-<td style="width: 7%;"></td>
181-<td style="width: 7%;">a</td>
182-<td style="width: 7%;"></td>
183-<td style="width: 7%;">b</td>
184-<td style="width: 7%;"></td>
185-<td style="width: 7%;">c</td>
186-<td style="width: 7%;">#0</td>
187-<td style="width: 7%;">#0</td>
188-</tr>
189-<tr>
190-<td colspan="4" style="width: 16%;">RefCount</td>
191-<td colspan="4" style="width: 16%;">Length</td>
192-<td></td>
193-<td></td>
194-<td></td>
195-<td></td>
196-<td></td>
197-<td></td>
198-<td></td>
199-<td></td>
200-</tr>
201-</tbody>
202-</table>
173+![Light bulb](https://upload.wikimedia.org/wikipedia/commons/d/d8/Nuvola_apps_ktip.png) **Remarque:** L'appelation UnicodeString est un peu ambiguë mais provient sans doute de son emploi dans Delphi sur Windows, où le système d'exploitation utilise l'encodage UTF-16 ; ce n'est pas le seul type de chaîne qui permet de contenir des données Unicode (voir aussi UTF8String)...
203174
175+| | | | | | | | | a | | b | | c | #0 | #0
176+---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---
177+RefCount | Length
178+
204179#### Référence
205180
206-- [Documentation FPC sur UnicodeString](http://www.freepascal.org/docs-html/ref/refsu13.html)
181+ * [Documentation FPC sur UnicodeString](<http://www.freepascal.org/docs-html/ref/refsu13.html>)
207182
208183## UTF8String
209184
210-Actuellement, le type **UTF8String** est un alias sur le type **AnsiString**. Il est destiné à contenir des chaînes encodées en UTF-8 (i.e. des données Unicode) allant de 1 à 4 octets par caractère. UTF8String est le type par défaut dans Lazarus et la LCL. UTF8String est le type de chaîne par défaut dans Lazarus et la LCL.
185+Actuellement, le type **UTF8String** est un alias sur le type **AnsiString**. Il est destiné à contenir des chaînes encodées en UTF-8 (i.e. des données Unicode) allant de 1 à 4 octets par caractère. UTF8String est le type par défaut dans Lazarus et la LCL. UTF8String est le type de chaîne par défaut dans Lazarus et la LCL.
211186
212187#### Référence
213188
214-- [[doc:rtl/system/utf8string.html|Documentation sur RTL UTF8String]]
189+ * [Documentation sur RTL UTF8String](<http://lazarus-ccr.sourceforge.net/docs/rtl/system/utf8string.html> "doc:rtl/system/utf8string.html")
215190
216191## UTF16String
217192
218-Le type **UTF16String** est un alias sur le type **WideString**. Dans l'unité LCL *lclproc*, c'est un alias sur **UnicodeString**.
193+Le type **UTF16String** est un alias sur le type **WideString**. Dans l'unité LCL _lclproc_ , c'est un alias sur **UnicodeString**.
219194
220195#### Référence
221196
222-- [[doc:lcl/lclproc/utf16string.html|Documentation sur LCL UTF16String]]
197+ * [Documentation sur LCL UTF16String](<http://lazarus-ccr.sourceforge.net/docs/lcl/lclproc/utf16string.html> "doc:lcl/lclproc/utf16string.html")
223198
224199## WideString
225200
226-Les variables du type **[[Widestrings/fr|WideString]]** (utilisées pour représenter les chaînes de caractères Unicode dans les applications COM) ressemblent à celle du type **UnicodeString**, mais contrairement à elles, elles ne bénéficient pas du comptage de références. Dans Windows, elles sont allouées une fonction spéciale de Windows qui leur permet d'être utilisées dans OLE Automation.
227-
228-Les WideStrings consistent en octets encodés UTF-16 comppatible COM sur les machines Windows (UCS2 sur Windows 2000) et elles sont encodées en UTF-16 pur sur Linux, Mac OS et iOS.
201+Les variables du type **[[Widestrings/fr|WideString]]** (utilisées pour représenter les chaînes de caractères Unicode dans les applications COM) ressemblent à celle du type **UnicodeString** , mais contrairement à elles, elles ne bénéficient pas du comptage de références. Dans Windows, elles sont allouées une fonction spéciale de Windows qui leur permet d'être utilisées dans OLE Automation.
229202
230-<table>
231-<tbody>
232-<tr>
233-<td style="width: 8%;"></td>
234-<td style="width: 8%;"></td>
235-<td style="width: 8%;"></td>
236-<td style="width: 8%;"></td>
237-<td style="width: 8%;"></td>
238-<td style="width: 8%;">a</td>
239-<td style="width: 8%;"></td>
240-<td style="width: 8%;">b</td>
241-<td style="width: 8%;"></td>
242-<td style="width: 8%;">c</td>
243-<td style="width: 8%;">#0</td>
244-<td style="width: 8%;">#0</td>
245-</tr>
246-<tr>
247-<td colspan="4" style="width: 16%;">Length</td>
248-<td></td>
249-<td></td>
250-<td></td>
251-<td></td>
252-<td></td>
253-<td></td>
254-<td></td>
255-<td></td>
256-</tr>
257-</tbody>
258-</table>
203+Les WideStrings consistent en octets encodés UTF-16 comppatible COM sur les machines Windows (UCS2 sur Windows 2000) et elles sont encodées en UTF-16 pur sur Linux, Mac OS et iOS.
259204
205+| | | | | a | | b | | c | #0 | #0
206+---|---|---|---|---|---|---|---|---|---|---|---
207+Length
208+
260209#### Référence
261210
262-- [Documentation FPC sur WideString](http://www.freepascal.org/docs-html/ref/refsu14.html#x37-400003.2.8)
211+ * [Documentation FPC sur WideString](<http://www.freepascal.org/docs-html/ref/refsu14.html#x37-400003.2.8>)
263212
264213## PShortString
265214
266-Une variable du type **PShortString** est un pointeur qui désigne le premier octet d'une variable de type **ShortString** (lequel définit la longueur de la ShortString).
267-
268-| | | | |
269-|-----|-----|-----|-----|
270-| \#3 | a | b | c |
271-| ^ | | | |
215+Une variable du type **PShortString** est un pointeur qui désigne le premier octet d'une variable de type **ShortString** (lequel définit la longueur de la ShortString).
272216
217+#3 | a | b | c
218+---|---|---|---
219+^
220+
273221#### Référence
274222
275-- [[doc:rtl/system/pshortstring.html|Documentation RTL sur PShortString]]
223+ * [Documentation RTL sur PShortString](<http://lazarus-ccr.sourceforge.net/docs/rtl/system/pshortstring.html> "doc:rtl/system/pshortstring.html")
276224
277225## PAnsiString
278226
279-Les variables de type **PAnsiString** sont des pointeurs sur des variables de type **AnsiString**. Néanmoins, contrairement aux variables de type **PShortString**, ils ne pointent pas sur le premier octet d'un en-tête mais sur le premier **char** de l**'AnsiString**.
280-
281-<table>
282-<tbody>
283-<tr>
284-<td style="width: 8%;"></td>
285-<td style="width: 8%;"></td>
286-<td style="width: 8%;"></td>
287-<td style="width: 8%;"></td>
288-<td style="width: 8%;"></td>
289-<td style="width: 8%;"></td>
290-<td style="width: 8%;"></td>
291-<td style="width: 8%;"></td>
292-<td style="width: 8%;">a</td>
293-<td style="width: 8%;">b</td>
294-<td style="width: 8%;">c</td>
295-<td style="width: 8%;">#0</td>
296-</tr>
297-<tr>
298-<td colspan="4" style="width: 16%;">RefCount</td>
299-<td colspan="4" style="width: 16%;">Length</td>
300-<td style="width: 8%;">^</td>
301-<td></td>
302-<td></td>
303-<td></td>
304-</tr>
305-</tbody>
306-</table>
227+Les variables de type **PAnsiString** sont des pointeurs sur des variables de type **AnsiString**. Néanmoins, contrairement aux variables de type **PShortString** , ils ne pointent pas sur le premier octet d'un en-tête mais sur le premier **char** de l'**AnsiString**.
307228
229+| | | | | | | | a | b | c | #0
230+---|---|---|---|---|---|---|---|---|---|---|---
231+RefCount | Length | ^
232+
308233#### Référence
309234
310-- [[doc:rtl/system/pansistring.html|Documentation RTL sur PAnsiString]]
235+ * [Documentation RTL sur PAnsiString](<http://lazarus-ccr.sourceforge.net/docs/rtl/system/pansistring.html> "doc:rtl/system/pansistring.html")
311236
312237## PUnicodeString
313238
314-Les variables de type **PUnicodeString** sont des pointeurs vers les variables de type **UnicodeString**.
315-
316-<table>
317-<tbody>
318-<tr>
319-<td style="width: 7%;"></td>
320-<td style="width: 7%;"></td>
321-<td style="width: 7%;"></td>
322-<td style="width: 7%;"></td>
323-<td style="width: 7%;"></td>
324-<td style="width: 7%;"></td>
325-<td style="width: 7%;"></td>
326-<td style="width: 7%;"></td>
327-<td style="width: 7%;"></td>
328-<td style="width: 7%;">a</td>
329-<td style="width: 7%;"></td>
330-<td style="width: 7%;">b</td>
331-<td style="width: 7%;"></td>
332-<td style="width: 7%;">c</td>
333-<td style="width: 7%;">#0</td>
334-<td style="width: 7%;">#0</td>
335-</tr>
336-<tr>
337-<td colspan="4" style="width: 16%;">RefCount</td>
338-<td colspan="4" style="width: 16%;">Length</td>
339-<td style="width: 7%;">^</td>
340-<td></td>
341-<td></td>
342-<td></td>
343-<td></td>
344-<td></td>
345-<td></td>
346-<td></td>
347-</tr>
348-</tbody>
349-</table>
239+Les variables de type **PUnicodeString** sont des pointeurs vers les variables de type **UnicodeString**.
350240
241+| | | | | | | | | a | | b | | c | #0 | #0
242+---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---
243+RefCount | Length | ^
244+
351245#### Référence
352246
353-- [[doc:rtl/system/punicodestring.html|Documentation RTL sur PUnicodeString]]
247+ * [Documentation RTL sur PUnicodeString](<http://lazarus-ccr.sourceforge.net/docs/rtl/system/punicodestring.html> "doc:rtl/system/punicodestring.html")
354248
355249## PWideString
356250
357-Les variables du type **PWideString** sont des pointeurs. Elles pointent sur le premier caractère d'une variable de type **WideString**.
358-
359-<table>
360-<tbody>
361-<tr>
362-<td style="width: 8%;"></td>
363-<td style="width: 8%;"></td>
364-<td style="width: 8%;"></td>
365-<td style="width: 8%;"></td>
366-<td style="width: 8%;"></td>
367-<td style="width: 8%;">a</td>
368-<td style="width: 8%;"></td>
369-<td style="width: 8%;">b</td>
370-<td style="width: 8%;"></td>
371-<td style="width: 8%;">c</td>
372-<td style="width: 8%;">#0</td>
373-<td style="width: 8%;">#0</td>
374-</tr>
375-<tr>
376-<td colspan="4" style="width: 16%;">Length</td>
377-<td style="width: 8%;">^</td>
378-<td></td>
379-<td></td>
380-<td></td>
381-<td></td>
382-<td></td>
383-<td></td>
384-<td></td>
385-</tr>
386-</tbody>
387-</table>
251+Les variables du type **PWideString** sont des pointeurs. Elles pointent sur le premier caractère d'une variable de type **WideString**.
388252
253+| | | | | a | | b | | c | #0 | #0
254+---|---|---|---|---|---|---|---|---|---|---|---
255+Length | ^
256+
389257#### Référence
390258
391-- [[doc:rtl/system/pwidestring.html|Documentation RTL sur PWideString]]
259+ * [Documentation RTL sur PWideString](<http://lazarus-ccr.sourceforge.net/docs/rtl/system/pwidestring.html> "doc:rtl/system/pwidestring.html")
392260
393261## Constantes String
394262
395-Si vous utilisez des constantes an Anglais, vos chaînes fonctionnent de la même façon avec tous les types, sur toutes les plateformes et toutes les versions du compilateur. Les chaînes 'non anglaises' peuvent eêtre chargées depuis des chaînes de ressource ou depuis des fichiers. Si vous utilisez des chaînes non anglaises dans votre code, vous devriez lire ce qui suit.
396-
397-There are various encodings for non English strings. By default Lazarus saves Pascal files as **UTF-8 without BOM**. UTF-8 supports the full Unicode range. That means all string constants are stored in UTF-8. Lazarus also supports to change the encoding of a file to other encoding, for example under Windows your local codepage. The Windows codepage is limited to your current language group.
263+Si vous utilisez des constantes an Anglais, vos chaînes fonctionnent de la même façon avec tous les types, sur toutes les plateformes et toutes les versions du compilateur. Les chaînes 'non anglaises' peuvent eêtre chargées depuis des chaînes de ressource ou depuis des fichiers. Si vous utilisez des chaînes non anglaises dans votre code, vous devriez lire ce qui suit.
398264
399-| String Type, UTF-8 Source | With or without {\$codepage utf8} | FPC 2.6.5 and below | FPC 2.7.1 and above | FPC 2.7.1+ with UTF8 as default CodePage |
400-|----|----|----|----|----|
401-| \|Without | Needs UTF8ToAnsi in RTL/WinAPI. Ok in LCL | Needs UTF8ToAnsi in RTL/WinAPI. Ok in LCL | Ok in RTL/W-WinAPI/LCL. Needs UTF8ToWinCP in A-WinAPI. | |
402-| \|With | System cp ok in RTL/WinAPI. Needs SysToUTF8 in LCL | Ok in RTL/WinAPI/LCL. Mixing with other strings converts to system cp | Ok in RTL/W-WinAPI/LCL. Needs UTF8ToWinCP in A-WinAPI | |
403-| \|Without | Wrong everywhere | Wrong everywhere | Wrong everywhere | |
404-| \|With | System cp ok in RTL/WinAPI. Needs UTF8Encode in LCL | Ok in RTL/WinAPI/LCL. Mixing with other strings converts to system cp | Ok in RTL/W-WinAPI/LCL. Needs UTF8ToWinCP in A-WinAPI | |
405-| \|Without | Same as AnsiString | Wrong everywhere | Wrong everywhere | |
406-| \|With | Same as AnsiString | Ok in RTL/WinAPI/LCL. Mixing with other strings converts to system cp | Ok in RTL/W-WinAPI/LCL. Needs UTF8ToWinCP in A-WinAPI. | |
265+
266+There are various encodings for non English strings. By default Lazarus saves Pascal files as **UTF-8 without BOM**. UTF-8 supports the full Unicode range. That means all string constants are stored in UTF-8. Lazarus also supports to change the encoding of a file to other encoding, for example under Windows your local codepage. The Windows codepage is limited to your current language group.
407267
408-- W-WinAPI = Windows API "W" functions, UTF-16
409-- A-WinAPI = Windows API non "W" functions, 8bit system code page
410-- System CP = The 8bit system code page of the OS. For example code page [1252](http://en.wikipedia.org/wiki/Windows-1252).
268+String Type, UTF-8 Source | With or without {$codepage utf8} | FPC 2.6.5 and below | FPC 2.7.1 and above | FPC 2.7.1+ with UTF8 as default CodePage
269+---|---|---|---|---
270+AnAnsiString:='ãü'; | Without | Needs UTF8ToAnsi in RTL/WinAPI. Ok in LCL | Needs UTF8ToAnsi in RTL/WinAPI. Ok in LCL | Ok in RTL/W-WinAPI/LCL. Needs UTF8ToWinCP in A-WinAPI.
271+AnAnsiString:='ãü'; | With | System cp ok in RTL/WinAPI. Needs SysToUTF8 in LCL | Ok in RTL/WinAPI/LCL. Mixing with other strings converts to system cp | Ok in RTL/W-WinAPI/LCL. Needs UTF8ToWinCP in A-WinAPI
272+AnUnicodeString:='ãü'; | Without | Wrong everywhere | Wrong everywhere | Wrong everywhere
273+AnUnicodeString:='ãü'; | With | System cp ok in RTL/WinAPI. Needs UTF8Encode in LCL | Ok in RTL/WinAPI/LCL. Mixing with other strings converts to system cp | Ok in RTL/W-WinAPI/LCL. Needs UTF8ToWinCP in A-WinAPI
274+AnUTF8String:='ãü'; | Without | Same as AnsiString | Wrong everywhere | Wrong everywhere
275+AnUTF8String:='ãü'; | With | Same as AnsiString | Ok in RTL/WinAPI/LCL. Mixing with other strings converts to system cp | Ok in RTL/W-WinAPI/LCL. Needs UTF8ToWinCP in A-WinAPI.
276+
277+ * W-WinAPI = Windows API "W" functions, UTF-16
278+ * A-WinAPI = Windows API non "W" functions, 8bit system code page
279+ * System CP = The 8bit system code page of the OS. For example code page [1252](<http://en.wikipedia.org/wiki/Windows-1252>).
411280
412-``` pascal
281+```
413282const
414- c='ãü';
415- cstring: string = 'ãü'; // see AnAnsiString:='ãü';
416-var
417- s: string;
418- u: UnicodeString;
419-begin
420- s:=c; // same as s:='ãü';
421- s:=cstring; // does not change encoding
422- u:=c; // same as u:='ãü';
423- u:=cstring; // fpc 2.6.1: converts from system cp to UTF-16, fpc 2.7.1+: depends on encoding of cstring
424-end;
283+ c='ãü';
284+ cstring: string = 'ãü'; // see AnAnsiString:='ãü';
285+ var
286+ s: string;
287+ u: UnicodeString;
288+ begin
289+ s:=c; // same as s:='ãü';
290+ s:=cstring; // does not change encoding
291+ u:=c; // same as u:='ãü';
292+ u:=cstring; // fpc 2.6.1: converts from system cp to UTF-16, fpc 2.7.1+: depends on encoding of cstring
293+ end;
425294```
426295
427296## Voir aussi
428297
429-- [[FPC Unicode support/fr|Support de l'Unicode par FPC]]
430-- [[LCL Unicode Support/fr|Support de l'Unicode par la LCL]]
431-- [[TStringList-TStrings Tutorial/fr|Tutoriel TStringList-TStrings]]
432-- [A Brief History of Strings](http://www.codexterity.com/delphistrings.htm)
298+ * [[FPC Unicode support/fr|Support de l'Unicode par FPC]]
299+ * [[LCL Unicode Support/fr|Support de l'Unicode par la LCL]]
300+ * [[TStringList-TStrings Tutorial/fr|Tutoriel TStringList-TStrings]]
301+ * [A Brief History of Strings](<http://www.codexterity.com/delphistrings.htm>)
433302
434303---
435-*From the Free Pascal wiki, page "Character and string types/fr", as it stood on 2020-02-10 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
304+*From the Free Pascal wiki, page "Character and string types/fr", as the Internet Archive kept it on 2024-09-08. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history