dreamingblackcat
dreamingblackcat

Reputation: 991

What is the difference between a string with escaped unicode characters and non-escaped unicode characters in javascript strings?

In javascript, especially in JSON, we can represent unicode characters with escape sequences or direct unicode string.

How does the two differ? Is there any practical implications or pitfalls in using one over another?

Upvotes: 0

Views: 1899

Answers (1)

Quentin
Quentin

Reputation: 943595

Escape sequences use ASCII characters so can be represented without having to worry about the encoding that the JS or JSON is transmitted / saved using. They require more bytes per encoded character. They aren't easy for a human to read by looking at source code.

None of the above are true when using a Unicode encoding (such as UTF-8).

Upvotes: 1

Related Questions