What should AnsiDequotedStr(s, #39) return for the following ansi string:

What should AnsiDequotedStr(s, #39) return for the following ansi string:
'bla 'blub''
?

Note that the string starts with a single quote and ends with two single quotes. These Quotes are part of the string's contents. (Assigned in code as
s := #39'bla '#39'blub'#39#39;)
#39 is the sinqle quote character.

I would have expected something like >bla 'blub'< or possibly >bla blub< But the actual result is >bla <.

So, apparently the second ' is interpreted as the end of the string.

Comments

  1. That is because the string is not correctly quoted in the first place. >bla 'blub'< would be quoted correctly as >'bla ''blub'''< (each single quote is doubled).

    ReplyDelete
  2. Uwe Raabe You are right. I originally took this string from the output in the Evaluate / Modify dialog of the Delphi 2007 IDE, assuming that it quoted the string correctly. It doesn't, as you can easily prove by clicking on the Modify button which results in the same broken content as in my example. So it's a case of garbage in, garbage out.

    ReplyDelete
  3. Daniela Osterhagen​ yes, I've added some more modifiers to the evaluate/modify dialog:
    ,u -> unquoted
    ,d -> date time
    Was a bit tricky

    ReplyDelete

Post a Comment