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

Comments

  1. Why not write 1-byte string literals as
    const
    AStr = AnsiString('that');
    Utf8Str = Utf8String('that');
    RBStr = RawByteString('that');

    ReplyDelete
  2. 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.

    ReplyDelete
  3. T n T just because "hello" is easy to use and with a compiler switch it do not break compatibility

    ReplyDelete
  4. To elaborate a bit more: I think the implicit conversion of string literals based on their context at compiletime is the issue.

    So 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.

    ReplyDelete
  5. 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.

    why are you against changing how to quote strings BTW ?

    ReplyDelete
  6. Because this would create an entire new category of rants and WTFs.

    Oh 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! :)

    ReplyDelete

Post a Comment