Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Encoding of source-code files in RAD 10.2 Tokyo


This question is not answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 6 - Last Post: Jan 7, 2018 10:48 PM Last Post By: Paulo França La...
Paulo França La...

Posts: 16
Registered: 1/26/17
Encoding of source-code files in RAD 10.2 Tokyo  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2017 3:39 AM
How to configure the source-code Editor to save files as "UTF-8 without BOM"?
I can see the "File format" contextual menu providing some encoding options, but the only UTF-8 listed produces the BOM. There's no "UTF-8 without BOM" option.

The problem with the BOM is:
Delphi 7 (and probably other oldies too) cannot handle it. So, when I try to compile with D7 the same project (BOM-marked by Tokyo), I got the following compile error:
"Illegal character in input file: 'ï' ($EF)"

Seattle and Berlin don't do that, just Tokyo.
Any advices?
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Encoding of source-code files in RAD 10.2 Tokyo [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2017 6:48 AM   in response to: Paulo França La... in response to: Paulo França La...
Paulo França Lacerda wrote:

How to configure the source-code Editor to save files in "UTF-8
without BOM" format? I can see the "File format" contextual menu
providing some encoding options, but the only UTF-8 listed produces
the BOM. There's no "UTF-8 without BOM" option.

The problem with the BOM is:
Delphi 7 (and probably other oldies too) cannot handle it. So, when
I try to compile with D7 the same project (BOM-marked by Tokyo), I
got the following compile error: +"_Illegal character in
input file: 'ï' ($EF)_"+

Seattle and Berlin don't do that, just Tokyo.

Actually Berlin at least does add a BOM.

If you only have source files that use plain ASCII characters simply
use the default ANSI encoding, it is fully equivalent to UTF-8 in this
case. If you do have characters with code points over #127 in the text
you goal cannot be reached, since such characters are encoded
differently in ANsI (Delphi 7) and UTF-8. Just leaving off the BOM may
allow D7 to load such a file, but it will not correctly interpret any
non-ASCII characters contained in the file (in string literals, that is
the only place they can occur).

--
Peter Below
TeamB

Paulo França La...

Posts: 16
Registered: 1/26/17
Re: Encoding of source-code files in RAD 10.2 Tokyo [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2017 9:00 AM   in response to: Peter Below in response to: Peter Below
Peter Below wrote:
Actually Berlin at least does add a BOM.
Not in my tests. Neither Seattle.

Peter Below wrote:
If you only have source files that use plain ASCII characters simply
use the default ANSI encoding, it is fully equivalent to UTF-8 in this
case. If you do have characters with code points over #127 in the text
you goal cannot be reached, since such characters are encoded
differently in ANsI (Delphi 7) and UTF-8. Just leaving off the BOM may
allow D7 to load such a file, but it will not correctly interpret any
non-ASCII characters contained in the file (in string literals, that is
the only place they can occur).
Actually, I need the same old behavior as before: to not change the "UTF-8 without BOM" encoding into anything else.
Before Tokyo, I used to compile all my stuff (whether saved in ANSI or UTF-8 w/o BOM) with any Delphi version (for both Win32/64) without any problems. Now, this. :/

Tokyo could provide a checkbox (for keeping the old behavior) somewhere in the Product (or Project) Options. This would be enough to prevent from breaking compatibility with previous compilers, mainly the ANSI-based ones.
Rudy Velthuis (...


Posts: 7,731
Registered: 9/22/99
Re: Encoding of source-code files in RAD 10.2 Tokyo [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 10, 2017 6:36 AM   in response to: Peter Below in response to: Peter Below
Peter Below wrote:

Paulo França Lacerda wrote:

How to configure the source-code Editor to save files in "UTF-8
without BOM" format? I can see the "File format" contextual menu
providing some encoding options, but the only UTF-8 listed produces
the BOM. There's no "UTF-8 without BOM" option.

The problem with the BOM is:
Delphi 7 (and probably other oldies too) cannot handle it. So,
when I try to compile with D7 the same project (BOM-marked by
Tokyo), I got the following compile error: +"_Illegal
character in input file: 'ï' ($EF)_"+

Seattle and Berlin don't do that, just Tokyo.

Actually Berlin at least does add a BOM.

So does Seattle. And so does XE2, so I assume that all versions
inbetween do the same.

--
Rudy Velthuis http://www.rvelthuis.de

"You have to stay in shape. My grandmother, she started walking
five miles a day when she was 60. She's 97 today and we don't
know where she is!" -- Ellen DeGeneres.
silvioprog *

Posts: 2
Registered: 4/28/09
Re: Encoding of source-code files in RAD 10.2 Tokyo
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 4, 2018 6:06 AM   in response to: Paulo França La... in response to: Paulo França La...
Paulo França Lacerda wrote:
How to configure the source-code Editor to save files as "UTF-8 without BOM"?

It seems Delphi does not provide an option like that, unfortunately. :-(

Many tools (SmartGit, CLion, Eclipse, MPLABX etc.) provides this option by tool and by project, so Delphi IDE should provide it too.

I can see the "File format" contextual menu providing some encoding options, but the only UTF-8 listed produces the BOM. There's no "UTF-8 without BOM" option.

Me too. But an option to set it in the entire project would be better, mainly for projects with hundreds units.

The problem with the BOM is:
Delphi 7 (and probably other oldies too) cannot handle it. So, when I try to compile with D7 the same project (BOM-marked by Tokyo), I got the following compile error:
"Illegal character in input file: 'ï' ($EF)"

Seattle and Berlin don't do that, just Tokyo.
Any advices?

I've got same problem for my encoding (Brazil, latin1) and unfortunately any file (.pas, *.inc, *.c, *.txt etc.) I load with Delphi's source editor, it change the file encoding, breaking my file. The Delphi IDE should leave the encoding of any file as it is!

Edited by: Silvio Clecio on Jan 4, 2018 6:14 AM
silvioprog *

Posts: 2
Registered: 4/28/09
Re: Encoding of source-code files in RAD 10.2 Tokyo  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 6, 2018 11:54 AM   in response to: silvioprog * in response to: silvioprog *
Another great feature: allow the programmer to choose the EOL of saved files from source editor.
Paulo França La...

Posts: 16
Registered: 1/26/17
Re: Encoding of source-code files in RAD 10.2 Tokyo  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 7, 2018 10:48 PM   in response to: silvioprog * in response to: silvioprog *
Thanks, Silvio, for the feedback. I'm glad that someone confirmed the problem.
Let's hope the issue will be address in a (not so long) future. :)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02