Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the \x1a characters mean

Tags:

php

mysql

ascii

What does the \x1a character mean and why does mysql_real_escape_string escape it?

From the documentation:

mysql_real_escape_string() calls MySQL's library function mysql_real_escape_string, which prepends backslashes to the following characters: \x00, \n, \r, \, ', " and \x1a.

A ASCII Characters reference describes it as Substitute character, but this doesn't say much.

like image 780
Emanuil Rusev Avatar asked Apr 27 '13 18:04

Emanuil Rusev


3 Answers

It's a Unicode escape sequence, in hexadecimal (base 16). \x1a is the "substitute" character.

See also: https://en.wikipedia.org/wiki/Substitute_character


Why does mysql_real_escape_string escape it?

According to the documentation,

Strictly speaking, MySQL requires only that backslash and the quote character used to quote the string in the query be escaped. mysql_real_escape_string() quotes the other characters to make them easier to read in log files.

like image 187
Matt Ball Avatar answered Nov 05 '22 20:11

Matt Ball


\x1A is CTRL+Z control character. It is also EOF marker.

like image 13
Ziumin Avatar answered Nov 05 '22 21:11

Ziumin


\x1a is a SUB control character, used to mark end of a file (EOF).

like image 4
keeri Avatar answered Nov 05 '22 19:11

keeri