Autor Beitrag
woully
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78



BeitragVerfasst: Mi 06.02.08 11:33 
Hallo zusammen,

bestimmt eine kleine sache, jedoch finde ich nicht die Lösung.

Ich verwende einen Widestring (BSTR bei COM), und mache folgendes :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var c: Char;
    s : widestring;
    b : Byte;
begin
 c := chr($91);
 s := s + c;
 b := ord(s[1]);
end;


Warum liefert mir hier das Byte "b" den Wert $18, und nicht $91 wie es eigentlich sein sollte ???

Danke

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
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: Mi 06.02.08 11:45 
Hallo,

Mit ord und chr muss man afaik bei Widestrings aufpassen - die funktionieren nur bei normalen Strings richtig. Das ist hier nicht das Problem - deine Werte liegen ja zwischen 0 und 255. Problem hier ist scheinbar, dass c nicht automatisch zu einem Widechar gecastet wird. So gehts:
ausblenden Delphi-Quelltext
1:
s := s + WideChar(c);					

_________________
We are, we were and will not be.
woully Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 78



BeitragVerfasst: Mi 06.02.08 11:50 
Hi,

stimmt.
funktionniert 1A.

Danke