Posts: 723
Threads: 366
Joined: Jun 2016
Hi,
I have some stuff where i need \t and \n can i write them into database? i don't use escaping because i know what i write. All is showing in dialog
Posts: 1,208
Threads: 36
Joined: Apr 2015
Write arbitrary data to the database you can be achieved by simple conversion:
PHP Code:
//Save example:
new tmpInput[256], tmpOutput[256 * 2];
format(tmpInput,sizeof tmpInput,"sdnajnda\n\tćłśą ...");
StringToHexString(tmpInput,tmpOutput);
//tmpOutput = "73646E616A6E64615C6E5C74E6B39CB9202E2E2E" - save this
//Load example:
new tmp_data[256], tmp_hexdata[256 * 2];
tmp_hexdata = "73646E616A6E64615C6E5C74E6B39CB9202E2E2E";
HexStringToString(tmp_hexdata,tmp_data);
//tmp_data = "sdnajnda\n\tćłśą ..."
Output data StringToHexString is two times greater than the input data.
Include:
ADM.inc
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
As far as I know it's perfectly possible to insert those characters into a database without resorting to methods like these. But I think the column needs to be set as TEXT, rather than CHAR or VARCHAR.
Posts: 723
Threads: 366
Joined: Jun 2016
tmpInput,
Primary text will not by changed?
Posts: 1,208
Threads: 36
Joined: Apr 2015
Posts: 723
Threads: 366
Joined: Jun 2016
But this is bad because i'am saving about ~100rows, so if there lenght >8126 i get mysql error, mysql line too long or smth..
Posts: 723
Threads: 366
Joined: Jun 2016
I think for \t, maybe i just can do spaces? how much spaces have \t?
Posts: 508
Threads: 9
Joined: Dec 2010
Reputation:
0
If you want to use \t or \n just escape it(put an extra \ before it).
Example:
"Text message\\t goes here\\n"