| Zitat: |
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; End; 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 Inc(pWc) Else If pWc^ = #$FFFE Then Begin SwapWideChars( pWc ); Inc( pWc ); End Else ; strings.Text := WideCharToString( pWc ); finally ms.free; end; End; | |
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?
Delphi-Quelltext
1:
| Procedure SaveAsUnicodeFile (Strings: TStrings; const filename: String); |