Autor Beitrag
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Mi 17.05.06 05:57 
Hi @all,

weiß jemand zufälligerweise, ob es Synonym für AnsiLastChar für WideStrings gibt? Denn WideLastChar gibt es ja leider nicht :(. Ich möchte einfach überprüfen, ob das letzte Zeichen des Strings ein "\" ist. Mein Problem ist u.a. auch, dass ich nicht weiß, ob man die Länge eines WideStrings auch einfach über length bestimmen darf und dann einfach aufs letzte Element zugreifen und es vergleichen kann, oder nicht.

//EDIT: Bin durch zufall auf den Source von den Tnt-Controls im Internet gekommen. Und da haben dies so gelöst:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
function WideLastChar(W: WideString): WideChar;
begin
  if Length(W) = 0 then
    Result := #0
  else
    Result := W[Length(W)];
end;

Also kann man doch length einfach verwenden bei WideString :).
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Mi 17.05.06 07:20 
Hi also für sowas gibt es doch IncludeTrailingBackslash(); :)

Weitere Nettigkeiten für Dateinamenmanipulation gibt es hier: www.dsdt.info/referenz/kategorie/?kat=5
Heiko Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Mi 17.05.06 13:52 
Hi, dass ist leider nicht WideString-fähig.
Ich habs jetzt so hier:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
lenFStr  := lstrlenW(PWideChar(FileName));
if lenFStr > 0 then
begin
  if FileName[lenFStr] <> '\' then
  begin
    if FileName[lenFStr] = '/' then FileName[lenFStr] := '\'
                               else FileName := FileName+'\'
  end;
end;
digi_c
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1905

W98, XP
D7 PE, Lazarus, WinAVR
BeitragVerfasst: Mi 17.05.06 15:54 
Ich dachte Delphi Strings wären Widestrings :oops: hab mich wohl geeirt...