Autor Beitrag
Muffin
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 99

WinXP Pro SP2
D7 Personal
BeitragVerfasst: So 02.10.05 17:00 
Zitat:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
Procedure TForm1.LoadUnicodeFile( const filename: String; strings: TStrings );
  Procedure SwapWideChars( p: PWideChar );
    Begin
      While p^ <> #0000 Do Begin
        p^ := WideChar(Swap( Word(p^)));
        Inc( p );
      End; { While }
    End; { SwapWideChars }
  Var
    ms: TMemoryStream;
    wc: WideChar;
    pWc: PWideChar;
  Begin
    ms:= TMemoryStream.Create;
    try
      ms.LoadFromFile( filename );
      ms.Seek( 0, soFromend );
      wc := #0000;
      ms.Write( wc, sizeof(wc));

      pWC := ms.Memory;
      If pWc^ = #$FEFF Then // normal byte order mark
        Inc(pWc)
      Else If pWc^ = #$FFFE Then Begin // byte order is big-endian
        SwapWideChars( pWc );
        Inc( pWc );
      End { If }
      Else ;  // no byte order mark
      strings.Text := WideCharToString( pWc );
    finally
      ms.free;
    end;
  End; { LoadUnicodeFile }


Ich habe diese tolle Prozedur im Forum gefunden. Hat mir wirklich sehr geholfen. Kann man sie auch wieder rückgängig machen? Also eine Prozedur die normale ANSIs wieder als Unicode big-endian speichert?

ausblenden Delphi-Quelltext
1:
Procedure SaveAsUnicodeFile (Strings: TStrings; const filename: String);					
Bernhard Geyer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 721
Erhaltene Danke: 3



BeitragVerfasst: Mo 03.10.05 08:54 
Im Elpack (www.lmd.de/products/lmdelpack/) oder in den TNTWare-Komponenten gibt es fertige Unicodefähige StringList-Komponenten. Diese können auch Unicodefähig Laden und Speichern.
Muffin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 99

WinXP Pro SP2
D7 Personal
BeitragVerfasst: Sa 15.10.05 13:14 
Ich glaube dein Beitrag über die cUnicodeCodecs von Delphi Fundamentals wird mir weiterhelfen.