Knowledge (XXG)

Escape character

Source šŸ“

483:) is used in many output devices to start a series of characters called a control sequence or escape sequence. Typically, the escape character was sent first in such a sequence to alert the device that the following characters were to be interpreted as a control sequence rather than as plain characters, then one or more characters would follow to specify some detailed action, after which the device would go back to interpreting characters normally. For example, the sequence of 47: 1206: 717:(which is used in PPP to mark the beginning and end of a frame) when those octets need to be transmitted by a higher level protocol encapsulated by PPP, as well as other octets negotiated when the link is established. That is, when a higher level protocol wishes to transmit 1210: 579:) escape character typically provides two ways to include double-quotes inside a string literal, either by modifying the meaning of the double-quote character embedded in the string ( 525:
is usually found on standard PC keyboards. However, it is commonly absent from keyboards for PDAs and other devices not designed primarily for ASCII communications. The DEC
533:
of the 1970sā€“1980s it was not uncommon to use this key as an escape character, but in modern desktop computers, such use is dropped. Sometimes the key was identified with
785:
remains unexpanded. So to refer to a file literally called "*", the shell must be told not to interpret it in this way, by preceding it with a backslash (
166:
In the telecommunications field, escape characters are used to indicate that the following characters are encoded differently. This is used to alter
670:
Some programming languages also provide other ways to represent special characters in literals, without requiring an escape character (see e.g.
529:
series was one of the few popular keyboards that did not have a dedicated Esc key, instead of using one of the keys above the main keypad. In
255:
In many programming languages, an escape character also forms some escape sequences which are referred to as control characters. For example,
1081: 159:
that invokes an alternative interpretation on the following characters in a character sequence. An escape character is a particular case of
1159: 130: 64: 215:, which cannot be typed in the current context, or would have an undesired interpretation. In this case, an escape sequence is a 1221: 111: 1215: 83: 68: 208:
To encode a syntactic entity, such as device commands or special data, which cannot be directly represented by the alphabet.
587:), or by modifying the meaning of a sequence of characters including the hexadecimal value of a double-quote character ( 90: 1247: 610: 606: 201:), which have to be interpreted differently from the same characters occurring without the prefixed escape character. 194: 365:
null character (U+0000 NULL) (only if the next character is not a decimal digit; else it is an octal escape sequence)
244:) then any escape character for this device is a control one. But escape characters used in programming (such as the 1026: 503:
covered by the ANSI X3.64 standard. The escape character also starts each command sequence in the Hewlett-Packard
97: 57: 1242: 1189: 1103: 598: 504: 79: 937:, the backslash is used as a path separator; therefore, it generally cannot be used as an escape character. 683: 537:(for alternative mode). Even with no dedicated key, the escape character code could be generated by typing 256: 186:
An escape character may not have its own meaning, so all escape sequences are of two or more characters.
1021: 252:"control characters" have some control function in isolation, therefore they are not escape characters. 156: 163:. Generally, the judgement of whether something is an escape character or not depends on the context. 1077: 556: 514:'s IBM technical publications, who is credited with inventing this mechanism during his work on the 439:"Using \\r \rWill imitate a carriage return, which means shifting to the start of the row" 170:
that would otherwise be noticed and acted on by the underlying telecommunications hardware, such as
336: 216: 1039:ā€“ in some conventions a leading character (such as an apostrophe) functions as an escape character 20: 1036: 766: 762: 496: 148: 774: 690: 500: 233: 229: 171: 167: 104: 27: 534: 1163: 1134: 1031: 994: 644: 622: 618: 237: 445:// can be used to clear the screen on some terminals. Windows uses \r\n instead of \n alone 248:, "\") are graphic, hence are not control characters. Conversely most (but not all) of the 1193: 198: 31: 778: 568: 530: 421:"Using \\t \twill shift the characters after \\t one tab length to the right" 193:
for many programming languages, data formats, and communication protocols. For a given
1236: 754: 241: 190: 160: 1056: 1225: 742: 640: 998: 878:
For example, on the Windows Command Prompt, this will result in a syntax error.
872: 626: 543: 464: 46: 1018:
used to type characters that are unusual for the locale of the keyboard layout.
938: 614: 522: 499:
to the 10th cell of the 2nd line of the screen. This was later developed into
35: 997:, which encodes 8-bit data into 7-bit data of limited line lengths, uses the 647:
to quote characters with a special meaning, as for non-ASCII characters. The
1197: 1015: 671: 648: 572: 564: 511: 245: 144: 843:) to escape reserved characters that have special meanings (in particular: 942: 746: 709:
before being passed to a higher level protocol. This is applied to both
403:"Using \\n \nWill shift the characters after \\n one row down" 197:
an escape character's purpose is to start character sequences (so named
174:. In this context, the use of escape characters is often referred to as 934: 832: 1186: 1111: 701:) as an escape character. The octet immediately following should be 228:
Generally, an escape character is not a particular case of (device)
602: 836: 526: 515: 492: 456: 249: 219:
consisting of an escape character itself and a "quoted" character.
660: 656: 702: 664: 636: 632: 510:
An early reference to the term "escape character" is found in
40: 613:
all allow exactly the same two backslash escape styles. The
236:, or as having a special meaning for an output device (e.g. 16:
Character used to quote special-purpose characters, e.g. '\'
1162:. Microsoft Developer Network. 2014-05-08. Archived from 232:, nor vice versa. If we define control characters as non- 655:) character may be considered as an escape character in 875:, though it has similar syntax, does not support this. 789:). This modifies the interpretation of the asterisk ( 1104:"How Bob Bemer Invented the ESCAPE Sequence and Key" 491:, would cause a Digital Equipment Corporation (DEC) 351:). If cross-browser compatibility is a concern, use 1187:
That Powerful ESCAPE Character -- Key and Sequences
1002: 901: 868: 864: 860: 856: 852: 848: 844: 840: 790: 786: 782: 770: 758: 750: 730: 726: 722: 718: 714: 710: 706: 698: 694: 687: 652: 592: 588: 584: 580: 576: 560: 538: 488: 484: 480: 476: 472: 468: 460: 380: 376: 368: 362: 356: 352: 348: 344: 340: 332: 326: 320: 314: 308: 302: 296: 290: 284: 277: 260: 71:. Unsourced material may be challenged and removed. 371:character represented by the hexadecimal byte "FF" 19:For escaping markup in Knowledge (XXG) edits, see 773:will expand to the names of all files in the 8: 806:# delete all files in the current directory 769:. Without a preceding escape character, an 204:The functions of escape sequences include: 383:escapes are not allowed in JSON strings. 131:Learn how and when to remove this message 542: 280:(backslash) as an escape character for: 211:To represent characters, referred to as 1057:"JavaScript character escape sequences" 1048: 895:The syntax of the command is incorrect. 487:, followed by the printable characters 900:whereas this will output the string: 7: 948:For example, the following command: 721:, it is transmitted as the sequence 559:specify the double-quote character ( 475:, also represented by the sequences 69:adding citations to reliable sources 1059:. Mathias Bynens. 21 December 2011 541:while simultaneously holding down 189:Escape characters are part of the 14: 1084:from the original on Dec 14, 2014 1078:"Special Characters (JavaScript)" 713:itself and the control character 1209: This article incorporates 1204: 1141:. MacMillan Technical Publishing 833:Windows command-line interpreter 781:there are such files, otherwise 777:that do not start with a period 621:also use backslash escapes. The 45: 1222:General Services Administration 1080:. Microsoft Developer Network. 56:needs additional citations for 1135:"The Windows NT Command Shell" 455:The ASCII "escape" character ( 1: 873:DOS command-line interpreter 659:and derived formats such as 551:Programming and data formats 1102:Bemer, Bob (Oct 25, 2003). 347:instead of a vertical tab ( 1266: 1027:Leaning toothpick syndrome 259:has an escape sequence of 25: 18: 1160:"about_Escape_Characters" 1005:) as an escape character. 817:# delete the file named * 950: 905: 880: 810: 802: 629:as an escape character. 505:Printer Command Language 388: 26:Not to be confused with 684:Point-to-Point Protocol 678:Communication protocols 617:language and Microsoft 1217:Federal Standard 1037C 1211:public domain material 827:Windows Command Prompt 451:ASCII escape character 1022:Escape sequences in C 557:programming languages 495:terminal to move its 276:JavaScript uses the 65:improve this article 923:<hello world> 902:<hello world> 763:wildcard characters 672:delimiter collision 337:Internet Explorer 9 1248:Control characters 1192:2016-03-25 at the 1037:Stropping (syntax) 929:Windows PowerShell 729:is transmitted as 625:encoding uses the 471:, or, in decimal, 230:control characters 172:illegal characters 168:control characters 149:telecommunications 80:"Escape character" 1133:Tim Hill (1998). 1114:on 4 January 2018 824: 823: 775:working directory 761:) characters are 501:ANSI escape codes 339:and older treats 224:Control character 213:character quoting 141: 140: 133: 115: 28:control character 1255: 1243:Pattern matching 1230: 1229: 1224:. Archived from 1208: 1207: 1175: 1174: 1172: 1171: 1156: 1150: 1149: 1147: 1146: 1130: 1124: 1123: 1121: 1119: 1110:. Archived from 1099: 1093: 1092: 1090: 1089: 1074: 1068: 1067: 1065: 1064: 1053: 1032:Nested quotation 1004: 995:Quoted-printable 980: 977: 974: 973: 970: 967: 964: 961: 958: 955: 924: 921: 920: 916: 913: 910: 903: 896: 893: 892:hello world> 891: 888: 885: 870: 866: 862: 858: 854: 850: 846: 842: 818: 815: 807: 796: 795: 792: 788: 784: 772: 760: 752: 732: 728: 724: 720: 716: 712: 708: 700: 696: 689: 654: 623:quoted-printable 619:Rich Text Format 594: 590: 586: 582: 578: 562: 540: 490: 486: 482: 478: 474: 470: 462: 446: 443: 440: 437: 434: 431: 428: 425: 422: 419: 416: 413: 410: 407: 404: 401: 398: 395: 392: 382: 378: 370: 364: 358: 354: 350: 346: 342: 334: 328: 322: 316: 310: 304: 298: 292: 286: 279: 262: 199:escape sequences 153:escape character 136: 129: 125: 122: 116: 114: 73: 49: 41: 1265: 1264: 1258: 1257: 1256: 1254: 1253: 1252: 1233: 1232: 1214: 1205: 1203: 1194:Wayback Machine 1183: 1178: 1169: 1167: 1158: 1157: 1153: 1144: 1142: 1139:Microsoft Learn 1132: 1131: 1127: 1117: 1115: 1101: 1100: 1096: 1087: 1085: 1076: 1075: 1071: 1062: 1060: 1055: 1054: 1050: 1046: 1012: 991: 982: 981: 978: 975: 971: 968: 965: 962: 959: 956: 953: 952: 945:( ` ) instead. 931: 926: 925: 922: 918: 914: 911: 908: 907: 898: 897: 894: 889: 886: 883: 882: 829: 820: 819: 816: 813: 809: 808: 805: 739: 686:(PPP) uses the 680: 553: 546: 531:user interfaces 518:character set. 453: 448: 447: 444: 441: 438: 435: 432: 429: 426: 423: 420: 417: 414: 411: 408: 405: 402: 399: 396: 393: 390: 311:carriage return 274: 269: 226: 184: 137: 126: 120: 117: 74: 72: 62: 50: 39: 32:escape sequence 24: 17: 12: 11: 5: 1263: 1262: 1259: 1251: 1250: 1245: 1235: 1234: 1228:on 2022-01-22. 1201: 1200: 1182: 1181:External links 1179: 1177: 1176: 1151: 1125: 1094: 1069: 1047: 1045: 1042: 1041: 1040: 1034: 1029: 1024: 1019: 1011: 1008: 1007: 1006: 990: 987: 986: 985: 972:New line" 951: 930: 927: 906: 881: 828: 825: 822: 821: 811: 803: 800: 779:if and only if 738: 735: 679: 676: 569:string literal 552: 549: 452: 449: 389: 373: 372: 366: 360: 335:vertical tab ( 330: 324: 318: 312: 306: 300: 294: 288: 273: 270: 268: 265: 225: 222: 221: 220: 209: 183: 180: 161:metacharacters 139: 138: 53: 51: 44: 15: 13: 10: 9: 6: 4: 3: 2: 1261: 1260: 1249: 1246: 1244: 1241: 1240: 1238: 1231: 1227: 1223: 1219: 1218: 1212: 1199: 1195: 1191: 1188: 1185: 1184: 1180: 1166:on 2016-11-25 1165: 1161: 1155: 1152: 1140: 1136: 1129: 1126: 1113: 1109: 1105: 1098: 1095: 1083: 1079: 1073: 1070: 1058: 1052: 1049: 1043: 1038: 1035: 1033: 1030: 1028: 1025: 1023: 1020: 1017: 1014: 1013: 1009: 1000: 996: 993: 992: 988: 984: 983: 949: 946: 944: 940: 936: 928: 904: 879: 876: 874: 838: 834: 826: 801: 798: 797: 794: 780: 776: 768: 765:expanded via 764: 756: 755:question mark 748: 744: 736: 734: 704: 692: 685: 677: 675: 673: 668: 666: 662: 658: 650: 646: 642: 638: 634: 630: 628: 624: 620: 616: 612: 608: 604: 600: 596: 574: 570: 566: 558: 550: 548: 545: 536: 532: 528: 524: 519: 517: 513: 508: 506: 502: 498: 494: 466: 458: 450: 387: 386:Example code: 384: 367: 361: 338: 331: 325: 319: 313: 307: 301: 295: 289: 283: 282: 281: 271: 266: 264: 258: 253: 251: 247: 243: 242:text terminal 239: 235: 231: 223: 218: 214: 210: 207: 206: 205: 202: 200: 196: 192: 187: 181: 179: 177: 173: 169: 164: 162: 158: 154: 150: 146: 135: 132: 124: 113: 110: 106: 103: 99: 96: 92: 89: 85: 82: ā€“  81: 77: 76:Find sources: 70: 66: 60: 59: 54:This article 52: 48: 43: 42: 37: 33: 29: 22: 1226:the original 1216: 1202: 1168:. Retrieved 1164:the original 1154: 1143:. Retrieved 1138: 1128: 1116:. Retrieved 1112:the original 1107: 1097: 1086:. Retrieved 1072: 1061:. Retrieved 1051: 947: 932: 899: 877: 830: 793:). Compare: 743:Bourne shell 740: 737:Bourne shell 697:, or ASCII: 681: 669: 631: 597: 555:Many modern 554: 520: 509: 454: 385: 374: 293:double quote 287:single quote 275: 254: 227: 212: 203: 188: 185: 175: 165: 152: 142: 127: 118: 108: 101: 94: 87: 75: 63:Please help 58:verification 55: 999:equals sign 954:PS C:\> 917:hello world 839:character ( 627:equals sign 465:hexadecimal 355:instead of 1237:Categories 1170:2016-11-24 1145:2010-01-13 1088:2014-06-30 1063:2014-06-30 1044:References 976:First line 966:First line 939:PowerShell 745:(sh), the 615:PostScript 523:Escape key 272:JavaScript 257:line break 182:Definition 121:April 2010 91:newspapers 36:Escape key 1198:Bob Bemer 1108:Bob Bemer 1016:AltGr key 731:0x7D 0x5E 723:0x7D 0x5D 649:ampersand 573:backslash 565:delimiter 512:Bob Bemer 349:'\x0B 329:form feed 323:backspace 299:backslash 246:backslash 157:character 145:computing 21:WP:NOWIKI 1190:Archived 1118:22 March 1082:Archived 1010:See also 979:New line 943:backtick 767:globbing 747:asterisk 591:becomes 583:becomes 305:new line 267:Examples 195:alphabet 935:Windows 909:C:\> 884:C:\> 871:). The 835:uses a 645:escapes 581:\" 563:) as a 535:AltMode 427:console 409:console 391:console 341:'\v 291:\" 238:printer 234:graphic 217:digraph 176:quoting 105:scholar 989:Others 960:" 799:  753:) and 725:, and 609:, and 593:" 585:" 571:. The 567:for a 561:" 497:cursor 489:[2;10H 345:'v 285:\' 191:syntax 107:  100:  93:  86:  78:  1213:from 957:echo 941:uses 919:^> 915:^< 845:& 837:caret 703:XORed 691:octet 653:& 527:VT220 516:ASCII 493:VT102 457:octal 250:ASCII 155:is a 151:, an 112:JSTOR 98:books 34:, or 1120:2018 912:echo 890:< 887:echo 865:> 861:< 831:The 727:0x7E 719:0x7D 715:0x7E 711:0x7D 707:0x20 695:\175 688:0x7D 682:The 663:and 661:HTML 657:SGML 639:use 635:and 611:Ruby 607:Java 589:\x22 544:Ctrl 521:The 469:\x1B 461:\033 379:and 375:The 369:\xFF 353:\x0B 147:and 84:news 933:In 804:rm* 741:In 705:by 674:). 665:XML 637:URI 633:URL 603:C++ 595:). 479:or 433:log 415:log 397:log 343:as 317:tab 240:or 143:In 67:by 1239:: 1220:. 1196:ā€“ 1137:. 1106:. 969:`n 963:`t 867:, 863:, 859:, 855:, 851:, 847:, 814:\* 812:rm 733:. 667:. 605:, 601:, 547:. 507:. 485:^[ 481:\e 477:^[ 473:27 467:: 463:, 459:: 381:\0 377:\v 363:\0 359:.) 357:\v 333:\v 327:\f 321:\b 315:\t 309:\r 303:\n 297:\\ 263:. 261:\n 178:. 30:, 1173:. 1148:. 1122:. 1091:. 1066:. 1003:= 1001:( 869:^ 857:) 853:( 849:| 841:^ 791:* 787:\ 783:* 771:* 759:? 757:( 751:* 749:( 699:} 693:( 651:( 643:- 641:% 599:C 577:\ 575:( 539:[ 442:) 436:( 430:. 424:) 418:( 412:. 406:) 400:( 394:. 278:\ 134:) 128:( 123:) 119:( 109:Ā· 102:Ā· 95:Ā· 88:Ā· 61:. 38:. 23:.

Index

WP:NOWIKI
control character
escape sequence
Escape key

verification
improve this article
adding citations to reliable sources
"Escape character"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
computing
telecommunications
character
metacharacters
control characters
illegal characters
syntax
alphabet
escape sequences
digraph
control characters
graphic
printer
text terminal
backslash

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

ā†‘