Autor Beitrag
Flamefire
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: So 30.09.07 13:34 
ich möchte einen Unicode-String (Widestring) an eine bestimmte stelle schreiben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure test();
var s:^WideChar;
s2:WideChar;
begin
  s:=Pointer(pText);
  s2:=WideChar('Hello World');
  s^ :=s2;
end;


pText ist eine Konstante wo der String hin soll.
So klappt das aber nicht. (ungültige umwandlung bei s2:=...)

Weis jemand wie das geht?
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 30.09.07 13:39 
Wenn ich das richtig in Erinnerung hab, so hier:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
const
    s: WideString = 'お元気です?';
var
    s2: WideString;
begin
    s2 := s;
end;


Bei älteren Delphi-Versionen gab's da aber immer Probleme.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 30.09.07 13:49 
Schau mal, ob es mit der Funktion StringToWideChar(); funktioniert. ;)
Flamefire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: So 30.09.07 13:53 
es geht ja darum, dass es an eine bestimmte addresse geschrieben werden soll
und das passiert nicht

hab mal das hier gemacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure test();
var s:^WideString;
s2:WideString;
begin
  s:=Pointer(pText);
  s2:='Hello World';
  MessageDlg('1:'+inttostr(Cardinal(s))+':'+s^,mtError,[mbOK],-1);
  s^ :=s2;
  MessageDlg('2:'+inttostr(Cardinal(s))+':'+s^,mtError,[mbOK],-1);
end;


Ausgabe:
1:[dasOffset]:
2:[dasOffset]:Hello World

ABER: an der Adresse stehn nur 4 Bytes
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: So 30.09.07 14:01 
Dann solltest Du Dir mal Move anschauen. Damit kannst Du Speicherbereiche kopieren.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.