request for unicode litteral strings like "this" and Ansi strings like 'that'
request for unicode litteral strings like "this" and Ansi strings like 'that'
https://quality.embarcadero.com/browse/RSP-21337
https://quality.embarcadero.com/browse/RSP-21337
https://quality.embarcadero.com/browse/RSP-21337
https://quality.embarcadero.com/browse/RSP-21337
Why not write 1-byte string literals as
ReplyDeleteconst
AStr = AnsiString('that');
Utf8Str = Utf8String('that');
RBStr = RawByteString('that');
I think Paul's point is that the compiler under the hood produces the string literals twice. You can see that when looking into the disassembly or the binary with a hex editor.
ReplyDeleteT n T just because "hello" is easy to use and with a compiler switch it do not break compatibility
ReplyDeleteTo elaborate a bit more: I think the implicit conversion of string literals based on their context at compiletime is the issue.
ReplyDeleteSo when I declare a const s = AnsiString('test') but assign that to a UnicodeString the compiler just turns it into a UnicodeString literal without any warning as would happen if I had a variable of type AnsiString.
So being able to turn off that cleverness of the compiler could be a solution. I haven't thought long and deep enough about this to tell what scope such an option should be though.
I am strictly against changing how to quote strings though.
Stefan Glienke and if the same const (like an XML or HTML template) is assigned both to an AnsiString and a UnicodeString, the template will be duplicated also.
ReplyDeletewhy are you against changing how to quote strings BTW ?
Because this would create an entire new category of rants and WTFs.
ReplyDeleteOh hey, I now cannot only say if I want zero or one based strings I can also specify via directive how I can quote them - hell no! :)