fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Escaping quotes like in C#?

Escaping quotes like in C#? 26 May 2020 18:11 #14721

  • pemo18's Avatar

  • pemo18

  • Topic Author


  • Posts: 35
  • Hello,

    Does X# supports the quoting mechanismn of C# like

    string sqlCommand = @"Select Nachname ""Nachnahme"" From Adressen";

    which results to Select Nachname "Nachnahme" From Adressen

    this would bei helpful for building SQL commands with aliases that works with Postgre for example.

    Right now we would use something like Nachname 'Nachname' and StrTran() for replacing ' with Chr(34) which works well

    Kind regards,
    Peter

    Please Log in or Create an account to join the conversation.

    Escaping quotes like in C#? 26 May 2020 19:22 #14723

  • lumberjack's Avatar

  • lumberjack


  • Posts: 685
  • Hi Peter,

    pemo18 wrote: Does X# supports the quoting mechanismn of C# like

    Yes
    string sqlCommand = @"Select Nachname ""Nachnahme"" From Adressen";
    LOCAL sqlCommand := "Select Nachname ""Nachnahme"" from Adressend" // Double quote notation AS STRING
    or
    LOCAL sqlCommand := e"Select Nachname \"Nachnahme\" from Adressend" // Escaped string \n\r\t etc...
    ______________________
    Johan Nel
    George, South Africa

    Please Log in or Create an account to join the conversation.

    Escaping quotes like in C#? 26 May 2020 20:55 #14727

  • pemo18's Avatar

  • pemo18

  • Topic Author


  • Posts: 35
  • Oh, thats good (so I did no try hard enough to make it work;)

    Regards,
    Peter

    Please Log in or Create an account to join the conversation.

    Escaping quotes like in C#? 26 May 2020 21:45 #14728

  • pemo18's Avatar

  • pemo18

  • Topic Author


  • Posts: 35
  • Hi Johan,

    Are you sure about the first option?

    I could only make it work with the second option (e and \) which I like better because its more readable.

    Regards,
    Peter

    Please Log in or Create an account to join the conversation.

    Escaping quotes like in C#? 26 May 2020 22:10 #14729

  • FFF's Avatar

  • FFF


  • Posts: 956
  • I think, Johan mixed the " and ' ...
    And don't forget, there are differences in behaviour between core and the dialects!

    @Chris, now you have the reason, why 'Chris is "great" ' should work, too, as does "Chris is 'great' "
    Some time ago we discussed why that's not handled equal ;)
    Regards
    Karl (X# 2.5a; Xide 1.25; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    Escaping quotes like in C#? 26 May 2020 23:12 #14730

  • Chris's Avatar

  • Chris


  • Posts: 1957
  • Never said that they should not both be supported! (the features I mean, not the content :))
    This is why they are both allowed now in X# for VO and other dialects (while single quotes were not supported in vulcan). In Core, this is not supported, in order to make the syntax more .Net-friendly, because .Net languages use single quotes for the Char type.

    About the "abc""def""ghi" syntax, this is indeed not supported, I remember we had discussed about it, but can't remember what was decided :). Will open a feature request for it.
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Escaping quotes like in C#? 27 May 2020 08:22 #14734

  • robert's Avatar

  • robert


  • Posts: 1746
  • Guys,
    Do you really want another string format ?
    We already have
    - double quoted strings ("abc'[]")
    - single quoted strings ('abc"[]')
    - bracketed strings ([abc'"])
    - interpolated strings (i"abc{i}")
    - extended strings ( e"\t\r\n")
    - extended interpolated strings (ei"\r{i}" and ie"\r{i}")
    - character literals ('a' or c'a')

    We are planning to add binary literals like in FoxPro (0h202020), but I personally think that is enough.

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Escaping quotes like in C#? 27 May 2020 09:44 #14736

  • FFF's Avatar

  • FFF


  • Posts: 956
  • Robert,
    i'd say, if ' "abc" ' works, like " 'abc' " does, it would be enough - but this variant indeed would come handy for the SQL writers...
    Regards
    Karl (X# 2.5a; Xide 1.25; W8.1/64 German)

    Please Log in or Create an account to join the conversation.

    Escaping quotes like in C#? 27 May 2020 11:20 #14738

  • Chris's Avatar

  • Chris


  • Posts: 1957
  • Robert,

    The problem is that single quoted strings do not work in Core dialect. Only way to workaround this is with escaped strings, but this syntax is difficult to read. So since c# supports the syntax "abc""def", I think it would be nice to support it in X# as well. Of course it's not high priority...
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1