Home > Web Front-end > JS Tutorial > Javascript octal escape character (octal)_javascript skills

Javascript octal escape character (octal)_javascript skills

WBOY
Release: 2016-05-16 18:08:12
Original
1895 people have browsed it

During the exploration process, I saw this character: "155", which is used to replace the character "m". Why? ....I don’t know the reason at all, and I suddenly panicked! Not to mention my 4 years of experience! "155" and "m" are congruent. I didn't know until now, in 2011, that I feel deeply ashamed!

For character escapes, the common ones are as follows:

"u5230" ==> "to"
"t" ==> horizontal tab "u0009"
"\ " ==> backslash "u005C"
"x35" ==> "5"
....

155 is converted from octal to decimal to 1*64 5*8 5=109
String.fromCharCode(109)==="m"

There are a total of 256 octal or hexadecimal escape characters

hexadecimal escape characters The fixed format is (2 digits):
x HexDigit HexDigit

Octal can have 1-3 digits, the maximum is "377", no relevant introduction was found in ECMA 262V5, guess what The method of String value (SV) is as follows:

1: Get the length value of character values ​​(CV) as len
2: len=Math.min(len,3)
3: Check whether the characters with length len after the escape character conform to the octal system. If so, go to step 5. Otherwise, step 4
4: len--, go to step 3
5: convert to get the corresponding characters. s0 is connected to the character after len

"1568a" ="n8a"
"

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template