PDA

View Full Version : Escaping slashes


ScIrUsna
18/04/2016, 10:38 AM
Hi,

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

http://wiki.sa-mp.com/wroot/index.php?title=Escape_codes&printable=yes

Maybe possible when loading disable slashes what i have escaped?

NaS
18/04/2016, 11:21 AM
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.

ScIrUsna
18/04/2016, 12:27 PM
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.

ScIrUsna
18/04/2016, 01:11 PM
Other question if can i escape a lot of times in a sec. ?

NaS
18/04/2016, 01:46 PM
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).

ScIrUsna
18/04/2016, 01:56 PM
Yes i too think that i need delete half of this "\" with strdel

NaS
18/04/2016, 02:43 PM
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.