Home teknologiaa Escape character

Escape character



Definition

Escapecharactersarepartoftheformalgrammarofmanyprogramminglanguages,dataformats,andcommunicationprotocols.Foragivenalphabet,thepurposeofanescapecharacteristostartacharactersequence,sothatthecharactersequenceatthebeginningoftheescapecharacterhasadifferentsemanticsthanwhenthecharactersequenceappearsalone.Therefore,thesequenceofcharactersatthebeginningoftheescapecharacteriscalledanescapesequence.

Escapesequencesusuallyhavetwofunctions.Thefirstistoencodeasyntacticentity,suchasadevicecommandorspecialdatathatcannotbedirectlyrepresentedbythealphabet.Thesecondfunction,alsocalledcharacterreference,isusedtoindicatecharactersthatcannotbeenteredbythekeyboardinthecurrentcontext(suchasthecarriagereturninastring),orcharactersthathaveundesiredmeaninginthecurrentcontext(suchasCThedoublequotecharacter"inthelanguagestringcannotappeardirectlyandmustbeexpressedbyanescapesequence).Inthelattercase,theescapesequenceisacombinationoftheescapecharacteritselfandaquotedcharacterLetter(digraph)situation.

Controlcharacters

Escapecharactersarenotcontrolcharacters;controlcharactersarenotescapecharacters.Ifthedefinitionofcontrolcharactersisanon-graphiccharacter,orCharacterswithspecialmeaningtooutputdevices(printers,textterminals),thentheescapecharactersforthesedevicesarealsocontrolcharacters.However,theescapecharactersusedinprogrammingaregraphiccharacters,sotheyarenotcontrolcharacters.Onthecontrary,mostASCIIcontrolcharactersalonehavecontrolfunctions,sotheyarenotescapecharacters.

Charactertable

Allescapecharactersandtheircorrespondingmeanings:

Escapecharacter

Meaning

ASCIIcodevalue(decimal)

\a

Bell(BEL)

007

\b

Backspace(BS),changethecurrentpositionMovetothepreviouscolumn

008

\f

Pagefeed(FF),movethecurrentpositiontothebeginningofthenextpage

012

\n

Linefeed(LF),movethecurrentpositiontothebeginningofthenextline

010

\r

Carriagereturn(CR),movethecurrentpositiontothislineBeginning

013

\t

HorizontalTabulation(HT)(skiptothenextTABposition)

009

\v

VerticalTabulation(VT)

011

\\

representsabackslashcharacter``\'

092

\'

representsasinglequote(apostrophe)character

039

\"

representsoneDoublequotecharacter

034

\?

representsaquestionmark

063

\0

Nullcharacter(NUL)

000

\ddd

Anycharacterrepresentedby1to3octalnumbers

Threeoctalnumbers

\xhh

Anycharacterrepresentedbyhexadecimal

Hexadecimal

Note:

1.Distinguish,Slash:"/"andbackslash:"\",herearenotinterchangeable

2.\xhhhexadecimalescapedoesnotlimitthenumberofcharacters'\x000000000000F'=='\xF'

Characterconstant

ThevaluerepresentedbythecharacterconstantintheClanguageisthevaluethattheinttypecancontain.WecanuseASCIIexpressionstorepresentacharacterconstant,orusesinglequoteswithbackslashestorepresentescapecharacters.

'A','\x2f','\013';

where:\xmeansthefollowingcharacterisahexadecimalnumber,\0meansthefollowingcharacterisOctalnumber.Forexample,17indecimalisrepresentedbyhexadecimal

'\x11',andrepresentedbyoctalis'\021';

The\x,\n,\aandsoonareallcalledescapecharacters,whichtellthecompilerthattheyneedtobeprocessedinaspecialway.

Composition

EscapeString(EscapeString),thatis,CharacterEntity(CharacterEntity)isdividedintothreeparts:thefirstpartisan&symbol,calledampersandinEnglish;thesecondpartistheentity(Entity)nameor#plustheentity(Entity)number;thethirdpartisasemicolon.

Forexample,todisplaythelessthansign(

Theadvantageofusingtheentitynameisthatitiseasiertounderstand.Whenyoulookatlt,youprobablyguessthemeaningoflessthan,butitsThedisadvantageisthatnotallbrowserssupportthelatestEntityname.Entitynumbercanbehandledbyvariousbrowsers.

Tips:Entitynameiscasesensitive.

Note:Thesamesymbolcanbequotedintwoways:"EntityName"and"EntityNumber".Theadvantageof"EntityName"isthatitiseasytoremember,butitdoesnotguaranteethatallbrowserscanrecognizeitsmoothly.It,andthe"entitynumber"doesnothavesuchconcerns,butitisreallyinconvenienttoremember.

Programminglanguage

SuchasHTMLescapecharacter,javaescapecharacter,xmlescape,Oracleescape,sqlescape,sqlserverescape,phpescape,asp,vb,javascript,etc.,aswellasthepercentsignintheURL.

Forexample,HTML<>&"©istheescapecharacterof&,",©;respectively

XMLhasonly5escapecharacters:<>&"'

Function

EscapeSequence(EscapeSequence)isalsocalledCharacterEntity.InHTML,thedefinitionofescapeTherearetworeasonsforstrings:Thefirstreasonisthatsymbolslike""havebeenusedtorepresentHTMLtags,sotheycannotbeuseddirectlyassymbolsintext.InordertousethesesymbolsinHTMLdocuments,theyneedtobedefinedItsescapedstring.Whentheinterpreterencountersthistypeofstring,itwillinterpretitasarealcharacter.Whenenteringanescapedstring,strictlyfollowtherulesoflettercase.ThesecondreasonisthatsomeCharactersarenotdefinedintheASCIIcharacterset,sotheyneedtoberepresentedbyescapedstrings.

Infact,inallprogramminglanguages,therearebasicallytworeasonsforhavingescapecharacters:1.UseescapecharacterstorepresentThecharactersdefinedinthecharacterset,suchasthecontrolcharactersinASCllandthecharacterssuchascarriagereturnandlinefeed,havenoready-madetextcodes.Therefore,theycanonlyberepresentedbyescapecharacters.Second,certainspecificcharactersareusedintheeditinglanguageDefinedasspecial-purposecharacters.Becausethesecharactersaredefinedasspecial-purposecharacters,theylosetheiroriginalmeaning.Forexample,inHtml,

Itcanalsobeseenfromtheabovethatescapingisnothingmorethantwosituations:1:Convertordinarycharacterstospecialpurposes,generallyusedinprogramminglanguages​​torepresentcharactersthatcannotbedirectlydisplayed,suchasthebackkey,enterkey,etc.2:Usedtoconvertthecharacterswithspecialmeaningbacktotheiroriginalmeaningrighteous.Generallyusedinregularexpressions.Therearealsosomescriptinglanguages​​thatareweaklytyped,somelanguages​​suchashtmlarenotprogramminglanguages,butmarkuplanguages,andsomelanguages​​haveonlyonetypesuchasshellscriptinglanguages.Thestringsintheselanguages​​arenotquoted"",ortheycanbeomittedQuotationmarks"",sosometimesitisnecessarytoescapecharacterstoindicatethatacharacter'sidentityatthistimeisanordinarycharacter,ratherthanametacharacterwithspecialmeaning.

Inaddition,forthesafetyofthewebsite.Beforedataiswrittentothedatabase,somesensitivecharactersareescapedusingescapecharacters(functions).Thiscanpreventsomepeoplewithulteriormotivesfromusingspecialsymbolinjectionattacks.

Showspaces

Usually,HTMLwillautomaticallycutoffextraspaces.Nomatterhowmanyspacesyouadd,itwillbetreatedasonespace.Forexample,ifyouadd10spacesbetweentwowords,HTMLwillcut9spacesandonlykeepone.Inordertoaddaspaceinthewebpage,youcanuse''toindicateaspace.

url

Inwebdevelopment,whenpassingavalueintheaddressbarofthebrowserthroughtheEnglishquestionmark(?).Thebrowserdistinguishesthenumberofparametersafterthequestionmarkthrough"&".Ifthereisan"&"inthevalueparameter,anerrorwillappearonthereceivingpage,similartothefollowingrequestpath:/next.jsp?param1=hendhs89&furej&param2=sss

ParametersThereisanescapecharacter"&"inparam1,whichwillcausetheparameterreceivingerroroftherequestedpage.

Afterencodingbyjava.net.URLEncoder.encode(param1)beforepassingthevalue,theescapecharactercanbeconvertedtohexadecimal;

Specialcharacters

UsageinURL

Escapemethod

+

(Space)

/

?

%

#

&

=

!

Representsaspace

%2B

Theplussign+or%20shouldbeusedinstead

%20

SeparateddirectoriesAndsubdirectories

%2F

SeparatetheactualURLandtheparameters

%3F

Specifyspecialcharacters

%25

meansbookmark

%23

TheseparatorbetweentheparametersspecifiedintheURL

%26

ThevalueofthespecifiedparameterintheURL

%3D

ThevalueofthespecifiedparameterintheURL

%21

This article is from the network, does not represent the position of this station. Please indicate the origin of reprint
TOP