0

The Rad Studio has an editor option for the file encoding. By default it's configured as Ansi and can be UTF-8 among others. If you want to change this default, for example, to UTF-8 this can be performed through the registry:

[HKEY_CURRENT_USER\Software\Embarcadero\BDS\20.0\Editor] "DefaultFileFilter"="Borland.FileFilter.UTF8ToUTF8"

Then, the files are saved as UTF-8 but with the BOM mark. The question is how can be saved as UTF-8 but without the BOM mark?

Ken White
  • 117,855
  • 13
  • 197
  • 405
Mauricio
  • 13
  • 2
  • Are you sure that is a good idea in the first place? Have you checked that the IDE is opening those files correctly? – Uwe Raabe Feb 20 '20 at 12:37
  • I have no tried extensively but, at first glance it's opening this files (utf-8 without bom) properly and saving changes witout adding the BOM mark. The thing that it is not a good idea it's to save UTF-8 with bom :) See https://stackoverflow.com/questions/2223882/whats-the-difference-between-utf-8-and-utf-8-without-bom – Mauricio Feb 20 '20 at 12:50
  • 3
    What is the actual problem you're trying to solve? – J... Feb 20 '20 at 13:11
  • 2
    @Mauricio Although the accepted answer you are linking to is quoting that the BOM is not recommended that is highly debatable as you can easily see by reading the many comments below it. Even more so in an environment that also has to deal with ANSI. Differentiating between UTF8 without BOM and ANSI is super error prone. – Stefan Glienke Feb 20 '20 at 13:26
  • 3
    If you remove the BOM mark from a file and then open it with the IDE, the file is regarded as an Ansi file, and subsequently saved as such. If you need it to be saved as UTF-8 (e.g. because of UTF-8 encoded text), you better leave the BOM as it is. – Tom Brunberg Feb 20 '20 at 13:27
  • @j I'm trying to work source as utf-8 without bom and they are saved by default with utf-8 with bom. There is no option for that in the editor. Maybe exists some registry parameter to do that. – Mauricio Feb 20 '20 at 13:29
  • 2
    But, as asked already by @J... , what is the actual problem you are trying to solve by removing the BOM??? Or, IOW, why do you dislike the BOM? – Tom Brunberg Feb 20 '20 at 13:31
  • I'm having trouble with git or gitkraken. I'm missing characters with commited UTF-8 files. I'll try to keep the source in ansi as much as possible and, if non-ascii characters are needed, try to use the value instead of character literal. I wanted to do this (configure it to save files as utf-8 without bom) because I know that there is no problem working in that way (Visual studio has this option). – Mauricio Feb 21 '20 at 12:55
  • @Mauricio Git should work fine with BOMs. If you want to ask a better question, ask that one - whatever the problem is you're having with Git is either a misconfiguration on your part or a defect on Git's part. Either way, it would make a good question (unless it's already a dupe...) – J... Feb 21 '20 at 13:32
  • @J... Thanks for the suggestion. I'll do more research to detect the source of the problem. Maybe those files where edited with another file editor/ide or some codepage mismatch/convertion format or something else. The problem, as you say, can be in git or gitkraken too. I saw that, without bom it's working fine and that was the reason of my question. I'll keep in mind to make another question if it's needed (and update this thread as possible). Thanks to all!. – Mauricio Feb 21 '20 at 13:53

1 Answers1

2

There is no option to do this. The BOM is required by the IDE to distinguish ANSI encoded files from UTF-8. If you remove the BOM the IDE will not properly identify the file as UTF-8 encoded.

J...
  • 28,957
  • 5
  • 61
  • 128