Escaping quotes like in C#?

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
pemo18
Posts: 72
Joined: Fri Apr 27, 2018 10:38 am
Location: Germany

Escaping quotes like in C#?

Post by pemo18 »

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
User avatar
lumberjack
Posts: 723
Joined: Fri Sep 25, 2015 3:11 pm

Escaping quotes like in C#?

Post by lumberjack »

Hi Peter,
pemo18 wrote: Does X# supports the quoting mechanismn of C# like
Yes

Code: Select all

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 nrt etc...
User avatar
pemo18
Posts: 72
Joined: Fri Apr 27, 2018 10:38 am
Location: Germany

Escaping quotes like in C#?

Post by pemo18 »

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

Regards,
Peter
User avatar
pemo18
Posts: 72
Joined: Fri Apr 27, 2018 10:38 am
Location: Germany

Escaping quotes like in C#?

Post by pemo18 »

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
FFF
Posts: 1522
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Escaping quotes like in C#?

Post by FFF »

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
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Escaping quotes like in C#?

Post by Chris »

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.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Escaping quotes like in C#?

Post by robert »

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"trn")
- 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
robert@xsharp.eu
FFF
Posts: 1522
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Escaping quotes like in C#?

Post by FFF »

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
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
Chris
Posts: 4562
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Escaping quotes like in C#?

Post by Chris »

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...
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply