Javascript Octal escape character (8 binary) _javascript tips
Source: Internet
Author: User
During the groping process, see such characters as "\155", used in place of the character "M". Why? .... Completely do not know the reason, the whole person suddenly panic! Don't say your 4 years of experience! "\155" and "M" is congruent, until now, 2011 years ago I know, deeply ashamed!
For character escape, the common is probably as follows:
155 converted from 8 to 10 to 1*64+5*8+5=109
String.fromCharCode (109) = = "M"
There are 256 or 8 binary and 16 escape characters in total
The 16-in-system escape character has a fixed format (2 digits):
\x Hexdigit Hexdigit
8 can have 1-3 digits, the maximum is "\377", in ECMA 262v5 did not find the relevant introduction, guess the way to get string value (SV) is the following steps:
1: Get character values (CV) length value of Len
2:len=math.min (len,3)
3: Check the length of Len after the escape character, whether it conforms to the 8 system, meet the 5th step, or step 4th
4:len--, to step 3rd.
5: Conversion to get the corresponding character s0 and Len bit after the character phase
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.