Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi is the Value Unicode or Ansi (https://www.delphipraxis.net/119023-value-unicode-ansi.html)

randy_dom 19. Aug 2008 20:28


is the Value Unicode or Ansi
 
Hi ,

How to detect if a File or a folder is a Unicode or Ansi with/out reading the BOM .

somthing like this :

Function IsUnicode(Value:String):Boolean;



Thanks

mkinzler 19. Aug 2008 20:29

Re: is the Value Unicode or Ansi
 
Ohne Lesen des Dateiheaders wird es nicht gehen

randy_dom 19. Aug 2008 20:36

Re: is the Value Unicode or Ansi
 
Zitat:

Zitat von mkinzler
Ohne Lesen des Dateiheaders wird es nicht gehen

How ?

Bernhard Geyer 19. Aug 2008 20:40

Re: is the Value Unicode or Ansi
 
Read the first 3 Bytes of the file for the BOM

randy_dom 19. Aug 2008 20:42

Re: is the Value Unicode or Ansi
 
Zitat:

Zitat von Bernhard Geyer
Read the first 3 Bytes of the file for the BOM

thank you Bernhard Geyer

Could you give me an example for that .

Bernhard Geyer 19. Aug 2008 20:51

Re: is the Value Unicode or Ansi
 
From JclUnicode.pas (JCL)

Delphi-Quellcode:
const
  BOM_LSB_FIRST = WideChar($FEFF);
  BOM_MSB_FIRST = WideChar($FFFE);


var
  BytesRead: Integer;
  Order: WideChar;
begin
  ...
    BytesRead := Stream.Read(Order, 2);
    if (Order = BOM_LSB_FIRST) or (Order = BOM_MSB_FIRST) then
   ...
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:59 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz