tags:

views:

934

answers:

4

Here's one from the "No question's too dumb" department:

Well, as the subject says: Is there an impact? If so, how much? Will all the string literals I have in my code and in my DFM resources now take up twice as much space inside the compiled binaries? What about runtime memory usage of compiled applications? Will all the string variables now take up twice as much RAM? Should I even bother?

I remember something like this being asked during one of the early pre-release webcasts but I can't remember the answer. And as the trial is only 14 days I'm not going to just try it myself before the third-party libraries I need have been updated (supposedly in about a month).

A: 

I haven't used Delphi in years, but it probably depends on what Unicode encoding they use. UTF8 will be exactly the same for the regular ASCII character set (it only uses more than one byte when you get into the exotic characters). UTF16 might be a bit bloated.

Neall
UTF-16 is usually smaller for languages that aren't based on Latin.
Barry Kelly
+2  A: 

D2009 uses UTF-16 for the default string type, although you can make variables UTF-8 if you need to.

Jan Goyvaerts discusses the size/speed tradeoff in a good blog post.

String literals in DFMs have been UTF-8 since at least D7. Hence, there will be no increase in size due to strings in DFMs with D2009.

Craig Stuntz
A: 

I have been waiting for an Unicode VCL for too many years, finally we see it. I don't think most applications need to worry about the size issues as they don't have that many string literals anyway or store massive amounts of data in-memory.

Usability issues are more weighted to justify Unicode use as much as possible.

If some developer wants to create a tiny exes, they can hand optimize using AnsiString (if i18n is not an issue).

A: 

I have now finally gotten my hands on Delphi 2009 and after making the necessary adjustments my project now compiles and runs just fine. :)

To get results quickly I initially had to comment out one slightly more complex module of the app so it's not 100% comparable yet but it already seems safe enough to predict that despite a significant amount of string literals in our source code (excessive debug log messages) the size of the binary compiled with Delphi 2009 will probably be roughly the same as before - if not actually less!

I wonder, does the Delphi compiler actually perform any kind of compression on the binaries or at least its resource sections in any way? I really would have expected the change to UTF-16 string literals to have a bigger impact in this particular app. Are the literals really stored as (uncompressed) UTF-16 inside the binary?

I haven't had time to investigate differences in the memory footprint yet.

EDIT: Not directly Unicode-related but definitely related: Andreas Hausladen recently posted an interesting bit about the (significant) impact of the {$STRINGCHECKS} compiler option (BTW: turned on by default) on compiled executable size: http://andy.jgknet.de/blog/?p=487

Oliver Giesen
No, it does not compress the binaries or its resources. You have to use an external third-party compressor for that, such as UPX.String literals that are assigned to UnicodeString variables in code will be stored as UTF-16 (and as UTF-8 when assigned to UTF8String variables, Ansi when assigned to AnsiString variables, etc).
Remy Lebeau - TeamB