Sql string to list dialog
#4

There is a difference between the \r\n that you retrieve from the database and the one that you create in a string in PAWN. I'm not sure if the precomiler changes it or not, but "Try\r\nThis" creating a string in PAWN is different to retrieving "Try\r\nThis" from the database. The ASCII characters are different in each of them. In example:

pawn Код:
new str[100], strx[100] = "Try\r\nThis";
mysql_fetch_row_format(str);
printf("str[0]: %d | str[1]: %d | str[2]: %d | str[3]: %d | str[4]: %d | str[5]: %d | str[6]: %d | str[7]: %d | str[8]: %d | str[9]: %d | str[10]: %d", str, str[0], str[1], str[2], str[3], str[4], str[5], str[6], str[7], str[8], str[9], str[10]);
printf("strx[0]: %d | strx[1]: %d | strx[2]: %d | strx[3]: %d | strx[4]: %d | strx[5]: %d | strx[6]: %d | strx[7]: %d | strx[8]: %d | strx[9]: %d | strx[10]: %d", strx, strx[0], strx[1], strx[2], strx[3], strx[4], strx[5], strx[6], strx[7], strx[8], strx[9], strx[10]);
This prints totally different things as it's actually printing \r\n in AScii characters rather than changing it into the newline.

Код:
[11:44:22] str[0]: 84 | str[1]: 84 | str[2]: 114 | str[3]: 121 | str[4]: 92 | str[5]: 114 | str[6]: 92 | str[7]: 110 | str[8]: 84 | str[9]: 104 | str[10]: 105
[11:44:22] strx[0]: 84 | strx[1]: 84 | strx[2]: 114 | strx[3]: 121 | strx[4]: 13 | strx[5]: 10 | strx[6]: 84 | strx[7]: 104 | strx[8]: 105 | strx[9]: 115 | strx[10]: 0
A solution for this may be using strReplace and finding "\r\n" and replacing it with "\r\n" although, I'm not fully sure that that will work either. If it doesn't try do something like this:

pawn Код:
new findstr[5];
findstr[0] = 92;
findstr[1] = 114;
findstr[2] = 92;
findstr[3] = 110;
strReplace(findstr, "\r\n", strsource, strdest);
I'm not sure if either of them will work but you could give it a try.
Reply


Messages In This Thread
Sql string to list dialog (Change line problem) - by rt-2 - 10.01.2012, 05:54
Re: Sql string to list dialog - by rt-2 - 19.01.2012, 23:18
Re: Sql string to list dialog - by rt-2 - 22.01.2012, 20:54
Re: Sql string to list dialog - by [HiC]TheKiller - 22.01.2012, 21:49
Re: Sql string to list dialog - by rt-2 - 06.03.2012, 21:24

Forum Jump:


Users browsing this thread: 3 Guest(s)