SA-MP Forums Archive
Escaping slashes - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Escaping slashes (/showthread.php?tid=605371)



Escaping slashes - ScIrUsna - 18.04.2016

Hi,

I see if i escape Backslash (\) i get 2 \\ and more more time player get saved it's get doubled slashes

https://sampwiki.blast.hk/wroot/index.ph...&printable=yes

Maybe possible when loading disable slashes what i have escaped?


Re: Escaping slashes - NaS - 18.04.2016

Does the \\ appear in the saved file? If yes you're doing something wrong.

You only have to escape them when you actually type it in a string or as a single character (like '\\') in your script.
If you load a "\" from a text file for example (or a player writes a backslash in a dialog), it is already escaped.

If I got your question wrong, please explain it a bit more.


Re: Escaping slashes - ScIrUsna - 18.04.2016

Yes \\ apear not \\ i see like that

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\

When player disconnect i save everytime info like all peoples safe, and i safe messages (PM) i use escape everytime before use mysql query to safe and when connect i load.


Re: Escaping slashes - ScIrUsna - 18.04.2016

Other question if can i escape a lot of times in a sec. ?


Re: Escaping slashes - NaS - 18.04.2016

Oh I thought you were working with files.

Whats your exact query to set the text containing a backslash?

Usually the backslash has to be escaped for a query in cleartext, so if you write the backslash in PAWN you have to make it \\\\. If you already have a backslash in a text you have to insert another \ ("\\" in PAWN). But I don't know if mysql_escape_* already does this, if yes don't escape twice.

You can also un-escape it everytime you load a string containing double backslash using for and strdel.

But I'm not very pro at MySQL, so you might want to wait for someone else to give their opinion or ****** it (it has been asked like a hundred times on stackoverflow with good solutions).


Re: Escaping slashes - ScIrUsna - 18.04.2016

Yes i too think that i need delete half of this "\" with strdel


Re: Escaping slashes - NaS - 18.04.2016

There should be a way without doing this though, seems more like a workaround.
You can try NO_BACKSLASH_ESCAPES SQL or changing the queries.