Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Encoding the same as Escaping?

I am interested in theory on whether Encoding is the same as Escaping? According to Wikipedia

an escape character is a character which invokes an alternative interpretation on subsequent characters in a character sequence.

My current thought is that they are different. Escaping is when you place an escape charater in front of a metacharacter(s) to mark it/them as to behave differently than what they would have normally.

Encoding, on the other hand, is all about transforming data into another form, and upon wanting to read the original content it is decoded back to its original form.

like image 828
Tower Avatar asked Dec 04 '10 15:12

Tower


People also ask

What are the 3 types of character encoding?

There are three different Unicode character encodings: UTF-8, UTF-16 and UTF-32.

What is escaping HTML?

HTML escaping is used to represent special characters in HTML code. For example, < less than symbol > has a special meaning in HTML markup language. This tool will convert a string to HTML entities or convert HTML entities to plain text.

What is encoding and escaping how it can be done in PHP *?

Because PHP programs often interact with HTML pages, web addresses (URLs), and databases, there are functions to help you work with those types of data. HTML, web page addresses, and database commands are all strings, but they each require different characters to be escaped in different ways.

What does escape data mean?

Escaping data is the process of securing output by stripping any unwanted data such as script tags, incorrectly formed HTML and other unwanted data. It therefore prevents of this data being seen or executed as code.


1 Answers

They're different, and I think you're getting the distinction correctly.

Encoding is when you transform between a logical representation of a text ("logical string", e.g. Unicode) into a well-defined sequence of binary digits ("physical string", e.g. ASCII, UTF-8, UTF-16). Escaping is a special character (typically the backslash: '\') which initiates a different interpretation of the character(s) following the escape character; escaping is necessary when you need to encode a larger number of symbols to a smaller number of distinct (and finite) bit sequences.

like image 77
Lie Ryan Avatar answered Sep 27 '22 18:09

Lie Ryan