Autor Beitrag
Georg08
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155
Erhaltene Danke: 6

Win XP
Delphi 7.0 Personal
BeitragVerfasst: Do 07.08.08 15:42 
Hallo, gibt es eine möglichkeit das Zeichen ' in eine Variable zu schreiben?
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 07.08.08 15:48 
ausblenden Delphi-Quelltext
1:
meineVar := '''';					

_________________
We are, we were and will not be.
Georg08 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155
Erhaltene Danke: 6

Win XP
Delphi 7.0 Personal
BeitragVerfasst: Do 07.08.08 15:55 
? wie soll '''' ' ' ' ergeben? im php is es \' geht das vllt hier auch?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Do 07.08.08 16:03 
Moin!

ausblenden Delphi-Quelltext
1:
MyStrOrChar := #39;					

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 07.08.08 16:05 
user profile iconGeorg08 hat folgendes geschrieben:
? wie soll '''' ' ' ' ergeben? im php is es \' geht das vllt hier auch?
Vielleicht einfach ausprobieren? :roll: Der doppelte '' zwischen den beiden einzelnen ' sorgt dafür, dass '''' als ' behandelt wird.

_________________
We are, we were and will not be.
baka0815
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 489
Erhaltene Danke: 14

Win 10, Win 8, Debian GNU/Linux
Delphi 10.1 Berlin, Java, C#
BeitragVerfasst: Do 07.08.08 17:03 
Erklärungsversuch:

Der Code von user profile iconGausi ist natürlich korrent: meineVar := '''';

Mit dem ersten ' fängst du den String an, mit dem letzten ' hört der String wieder auf. Soweit so gut.
Wenn man nun ein einfaches ' einfügen würde, würde Delphi "denken", dass der String dort bereits zu Ende wäre und den Fehler anmeckern, dass hinter dem String (meineVar := ''';) ja noch ein ' steht.

Die Delphi-Entwickler haben es sich jedoch nicht bei C abgeguckt und den Backslash als escape character verwendet, sondern eben die Dopplung des einzelnen Anführungszeichen (vgl. mit SQL).
Somit entspricht '' (zwei einzelne ') im String schließlich einem '.

WriteLn('Dies is''n Test'); gibt somit "Dies is'n Test" auf der Kommandozeile aus.