JS Control character Processing

Source: Internet
Author: User

Using JS when you go to a JSON object on a JSON string, if you encounter some control (special) characters, there will be a case of conversion failure

Processing methods: Usually we can replace these control characters with empty

function character (str) {    return str.replace (/\u0000|\u0001|\u0002|\u0003|\u0004|\u0005|\u0006|\ u0007|\u0008|\u0009|\u000a|\u000b|\u000c|\u000d|\u000e|\u000f|\u0010|\u0011|\u0012|\u0013|\u0014|\u0015|\u0016 |\u0017|\u0018|\u0019|\u001a|\u001b|\u001c|\u001d|\u001e|\u001f|\u007f/g, "");}

control characters in ASCII :

decimal hexadecimal control characters Escape Character Description Ctrl + the following letters
0 00 NUL / null character (null character) @
1 01 SOH Start of header (start of title) A
2 02 STX Start of text (body start) B
3 03 ETX End of text (body end) C
4 04 EOT End of transmission (transfer end) D
5 05 ENQ Enquiry (Request) E
6 06 Ack Acknowledgment (receive notification/response) F
7 07 BEL \a Bell (Bell) G
8 08 Bs \b Backspace (BACKSPACE) H
9 09 HT \ t Horizontal tab (Horizontal tab) I
10 0A LF \ n Line feed (newline key) J
11 0B Vt \v Vertical tab (Vertical tab) K
12 0C Ff \f Form Feed (page-change key) L
13 0D CR \ r Carriage return (Enter) M
14 0E So Shift out (without switching) N
15 0F SI Shift in (Enable toggle) O
16 10 DLE Data link escape (link escaping) P
17 11 DC1 Device Control 1 (Unit 1)/xon (transmit on) Q
18 12 DC2 Device Control 2 (Equipment controls 2) R
19 13 DC3 Device Control 3 (Unit 3)/xoff (transmit OFF) S
20 14 DC4 Device Control 4 (Equipment controls 4) T
21st 15 NAK Negative acknowledgement (reject receive/no response) U
22 16 Syn Synchronous Idle (Synchronous idle) V
23 17 ETB End of Trans The block (end of transmission block) W
24 18 CAN Cancel (canceled) X
25 19 Em End of Medium (to media end/media storage full) Y
26 1 A SUB Substitute (substitute/replace) Z
27 1 b Esc \e Escape (Overflow/escape/cancel) [
28 1C Fs File Separator (filename separator) \
29 1D Gs Group Separator (Group character) ]
30 1E Rs Record Separator (recording delimiter) ^
31 1F US Unit Separator (cell delimiter) _
32 20 Sp White space [Space]
127 7F Del Delete (remove) ?

JS Control character Processing

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.