CINXE.COM
String literal - Wikipedia
<!DOCTYPE html> <html class="client-nojs vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-toc-available" lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title>String literal - Wikipedia</title> <script>(function(){var className="client-js vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-sticky-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-feature-night-mode-enabled skin-theme-clientpref-day vector-toc-available";var cookie=document.cookie.match(/(?:^|; )enwikimwclientpreferences=([^;]+)/);if(cookie){cookie[1].split('%2C').forEach(function(pref){className=className.replace(new RegExp('(^| )'+pref.replace(/-clientpref-\w+$|[^\w-]+/g,'')+'-clientpref-\\w+( |$)'),'$1'+pref+'$2');});}document.documentElement.className=className;}());RLCONF={"wgBreakFrames":false,"wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy", "wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgRequestId":"52facf52-9671-4d8f-804c-1cf12e2b2a7b","wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"String_literal","wgTitle":"String literal","wgCurRevisionId":1254523808,"wgRevisionId":1254523808,"wgArticleId":199706,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Articles with short description","Short description matches Wikidata","All articles with unsourced statements","Articles with unsourced statements from March 2011","Articles with unsourced statements from February 2012","Articles with example Python (programming language) code","Source code","String (computer science)"],"wgPageViewLanguage":"en","wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgRelevantPageName":"String_literal","wgRelevantArticleId":199706, "wgIsProbablyEditable":true,"wgRelevantPageIsProbablyEditable":true,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgRedirectedFrom":"Literal_string","wgNoticeProject":"wikipedia","wgCiteReferencePreviewsActive":false,"wgFlaggedRevsParams":{"tags":{"status":{"levels":1}}},"wgMediaViewerOnClick":true,"wgMediaViewerEnabledByDefault":true,"wgPopupsFlags":0,"wgVisualEditor":{"pageLanguageCode":"en","pageLanguageDir":"ltr","pageVariantFallbacks":"en"},"wgMFDisplayWikibaseDescriptions":{"search":true,"watchlist":true,"tagline":false,"nearby":true},"wgWMESchemaEditAttemptStepOversample":false,"wgWMEPageLength":50000,"wgInternalRedirectTargetUrl":"/wiki/String_literal","wgRelatedArticlesCompat":[],"wgCentralAuthMobileDomain":false,"wgEditSubmitButtonLabelPublish":true,"wgULSPosition":"interlanguage","wgULSisCompactLinksEnabled":false,"wgVector2022LanguageInHeader":true,"wgULSisLanguageSelectorEmpty":false,"wgWikibaseItemId":"Q4736519","wgCheckUserClientHintsHeadersJsApi":["brands", "architecture","bitness","fullVersionList","mobile","model","platform","platformVersion"],"GEHomepageSuggestedEditsEnableTopics":true,"wgGETopicsMatchModeEnabled":false,"wgGEStructuredTaskRejectionReasonTextInputEnabled":false,"wgGELevelingUpEnabledForUser":false};RLSTATE={"ext.globalCssJs.user.styles":"ready","site.styles":"ready","user.styles":"ready","ext.globalCssJs.user":"ready","user":"ready","user.options":"loading","ext.pygments":"ready","ext.cite.styles":"ready","skins.vector.search.codex.styles":"ready","skins.vector.styles":"ready","skins.vector.icons":"ready","ext.wikimediamessages.styles":"ready","ext.visualEditor.desktopArticleTarget.noscript":"ready","ext.uls.interlanguage":"ready","wikibase.client.init":"ready","ext.wikimediaBadges":"ready"};RLPAGEMODULES=["mediawiki.action.view.redirect","ext.pygments.view","ext.cite.ux-enhancements","site","mediawiki.page.ready","mediawiki.toc","skins.vector.js","ext.centralNotice.geoIP","ext.centralNotice.startUp", "ext.gadget.ReferenceTooltips","ext.gadget.switcher","ext.urlShortener.toolbar","ext.centralauth.centralautologin","mmv.bootstrap","ext.popups","ext.visualEditor.desktopArticleTarget.init","ext.visualEditor.targetLoader","ext.echo.centralauth","ext.eventLogging","ext.wikimediaEvents","ext.navigationTiming","ext.uls.interface","ext.cx.eventlogging.campaigns","ext.cx.uls.quick.actions","wikibase.client.vector-2022","ext.checkUser.clientHints","ext.quicksurveys.init","ext.growthExperiments.SuggestedEditSession","wikibase.sidebar.tracking"];</script> <script>(RLQ=window.RLQ||[]).push(function(){mw.loader.impl(function(){return["user.options@12s5i",function($,jQuery,require,module){mw.user.tokens.set({"patrolToken":"+\\","watchToken":"+\\","csrfToken":"+\\"}); }];});});</script> <link rel="stylesheet" href="/w/load.php?lang=en&modules=ext.cite.styles%7Cext.pygments%2CwikimediaBadges%7Cext.uls.interlanguage%7Cext.visualEditor.desktopArticleTarget.noscript%7Cext.wikimediamessages.styles%7Cskins.vector.icons%2Cstyles%7Cskins.vector.search.codex.styles%7Cwikibase.client.init&only=styles&skin=vector-2022"> <script async="" src="/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022"></script> <meta name="ResourceLoaderDynamicStyles" content=""> <link rel="stylesheet" href="/w/load.php?lang=en&modules=site.styles&only=styles&skin=vector-2022"> <meta name="generator" content="MediaWiki 1.44.0-wmf.4"> <meta name="referrer" content="origin"> <meta name="referrer" content="origin-when-cross-origin"> <meta name="robots" content="max-image-preview:standard"> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=1120"> <meta property="og:title" content="String literal - Wikipedia"> <meta property="og:type" content="website"> <link rel="preconnect" href="//upload.wikimedia.org"> <link rel="alternate" media="only screen and (max-width: 640px)" href="//en.m.wikipedia.org/wiki/String_literal"> <link rel="alternate" type="application/x-wiki" title="Edit this page" href="/w/index.php?title=String_literal&action=edit"> <link rel="apple-touch-icon" href="/static/apple-touch/wikipedia.png"> <link rel="icon" href="/static/favicon/wikipedia.ico"> <link rel="search" type="application/opensearchdescription+xml" href="/w/rest.php/v1/search" title="Wikipedia (en)"> <link rel="EditURI" type="application/rsd+xml" href="//en.wikipedia.org/w/api.php?action=rsd"> <link rel="canonical" href="https://en.wikipedia.org/wiki/String_literal"> <link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en"> <link rel="alternate" type="application/atom+xml" title="Wikipedia Atom feed" href="/w/index.php?title=Special:RecentChanges&feed=atom"> <link rel="dns-prefetch" href="//meta.wikimedia.org" /> <link rel="dns-prefetch" href="//login.wikimedia.org"> </head> <body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject mw-editable page-String_literal rootpage-String_literal skin-vector-2022 action-view"><a class="mw-jump-link" href="#bodyContent">Jump to content</a> <div class="vector-header-container"> <header class="vector-header mw-header"> <div class="vector-header-start"> <nav class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-dropdown" class="vector-dropdown vector-main-menu-dropdown vector-button-flush-left vector-button-flush-right" > <input type="checkbox" id="vector-main-menu-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-main-menu-dropdown" class="vector-dropdown-checkbox " aria-label="Main menu" > <label id="vector-main-menu-dropdown-label" for="vector-main-menu-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-menu mw-ui-icon-wikimedia-menu"></span> <span class="vector-dropdown-label-text">Main menu</span> </label> <div class="vector-dropdown-content"> <div id="vector-main-menu-unpinned-container" class="vector-unpinned-container"> <div id="vector-main-menu" class="vector-main-menu vector-pinnable-element"> <div class="vector-pinnable-header vector-main-menu-pinnable-header vector-pinnable-header-unpinned" data-feature-name="main-menu-pinned" data-pinnable-element-id="vector-main-menu" data-pinned-container-id="vector-main-menu-pinned-container" data-unpinned-container-id="vector-main-menu-unpinned-container" > <div class="vector-pinnable-header-label">Main menu</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-main-menu.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-main-menu.unpin">hide</button> </div> <div id="p-navigation" class="vector-menu mw-portlet mw-portlet-navigation" > <div class="vector-menu-heading"> Navigation </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-mainpage-description" class="mw-list-item"><a href="/wiki/Main_Page" title="Visit the main page [z]" accesskey="z"><span>Main page</span></a></li><li id="n-contents" class="mw-list-item"><a href="/wiki/Wikipedia:Contents" title="Guides to browsing Wikipedia"><span>Contents</span></a></li><li id="n-currentevents" class="mw-list-item"><a href="/wiki/Portal:Current_events" title="Articles related to current events"><span>Current events</span></a></li><li id="n-randompage" class="mw-list-item"><a href="/wiki/Special:Random" title="Visit a randomly selected article [x]" accesskey="x"><span>Random article</span></a></li><li id="n-aboutsite" class="mw-list-item"><a href="/wiki/Wikipedia:About" title="Learn about Wikipedia and how it works"><span>About Wikipedia</span></a></li><li id="n-contactpage" class="mw-list-item"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us" title="How to contact Wikipedia"><span>Contact us</span></a></li> </ul> </div> </div> <div id="p-interaction" class="vector-menu mw-portlet mw-portlet-interaction" > <div class="vector-menu-heading"> Contribute </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="n-help" class="mw-list-item"><a href="/wiki/Help:Contents" title="Guidance on how to use and edit Wikipedia"><span>Help</span></a></li><li id="n-introduction" class="mw-list-item"><a href="/wiki/Help:Introduction" title="Learn how to edit Wikipedia"><span>Learn to edit</span></a></li><li id="n-portal" class="mw-list-item"><a href="/wiki/Wikipedia:Community_portal" title="The hub for editors"><span>Community portal</span></a></li><li id="n-recentchanges" class="mw-list-item"><a href="/wiki/Special:RecentChanges" title="A list of recent changes to Wikipedia [r]" accesskey="r"><span>Recent changes</span></a></li><li id="n-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_upload_wizard" title="Add images or other media for use on Wikipedia"><span>Upload file</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> <a href="/wiki/Main_Page" class="mw-logo"> <img class="mw-logo-icon" src="/static/images/icons/wikipedia.png" alt="" aria-hidden="true" height="50" width="50"> <span class="mw-logo-container skin-invert"> <img class="mw-logo-wordmark" alt="Wikipedia" src="/static/images/mobile/copyright/wikipedia-wordmark-en.svg" style="width: 7.5em; height: 1.125em;"> <img class="mw-logo-tagline" alt="The Free Encyclopedia" src="/static/images/mobile/copyright/wikipedia-tagline-en.svg" width="117" height="13" style="width: 7.3125em; height: 0.8125em;"> </span> </a> </div> <div class="vector-header-end"> <div id="p-search" role="search" class="vector-search-box-vue vector-search-box-collapses vector-search-box-show-thumbnail vector-search-box-auto-expand-width vector-search-box"> <a href="/wiki/Special:Search" class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only search-toggle" title="Search Wikipedia [f]" accesskey="f"><span class="vector-icon mw-ui-icon-search mw-ui-icon-wikimedia-search"></span> <span>Search</span> </a> <div class="vector-typeahead-search-container"> <div class="cdx-typeahead-search cdx-typeahead-search--show-thumbnail cdx-typeahead-search--auto-expand-width"> <form action="/w/index.php" id="searchform" class="cdx-search-input cdx-search-input--has-end-button"> <div id="simpleSearch" class="cdx-search-input__input-wrapper" data-search-loc="header-moved"> <div class="cdx-text-input cdx-text-input--has-start-icon"> <input class="cdx-text-input__input" type="search" name="search" placeholder="Search Wikipedia" aria-label="Search Wikipedia" autocapitalize="sentences" title="Search Wikipedia [f]" accesskey="f" id="searchInput" > <span class="cdx-text-input__icon cdx-text-input__start-icon"></span> </div> <input type="hidden" name="title" value="Special:Search"> </div> <button class="cdx-button cdx-search-input__end-button">Search</button> </form> </div> </div> </div> <nav class="vector-user-links vector-user-links-wide" aria-label="Personal tools"> <div class="vector-user-links-main"> <div id="p-vector-user-menu-preferences" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-userpage" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-dropdown" class="vector-dropdown " title="Change the appearance of the page's font size, width, and color" > <input type="checkbox" id="vector-appearance-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-appearance-dropdown" class="vector-dropdown-checkbox " aria-label="Appearance" > <label id="vector-appearance-dropdown-label" for="vector-appearance-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance"></span> <span class="vector-dropdown-label-text">Appearance</span> </label> <div class="vector-dropdown-content"> <div id="vector-appearance-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <div id="p-vector-user-menu-notifications" class="vector-menu mw-portlet emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> <div id="p-vector-user-menu-overflow" class="vector-menu mw-portlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en" class=""><span>Donate</span></a> </li> <li id="pt-createaccount-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:CreateAccount&returnto=String+literal" title="You are encouraged to create an account and log in; however, it is not mandatory" class=""><span>Create account</span></a> </li> <li id="pt-login-2" class="user-links-collapsible-item mw-list-item user-links-collapsible-item"><a data-mw="interface" href="/w/index.php?title=Special:UserLogin&returnto=String+literal" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o" class=""><span>Log in</span></a> </li> </ul> </div> </div> </div> <div id="vector-user-links-dropdown" class="vector-dropdown vector-user-menu vector-button-flush-right vector-user-menu-logged-out" title="Log in and more options" > <input type="checkbox" id="vector-user-links-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-user-links-dropdown" class="vector-dropdown-checkbox " aria-label="Personal tools" > <label id="vector-user-links-dropdown-label" for="vector-user-links-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-ellipsis mw-ui-icon-wikimedia-ellipsis"></span> <span class="vector-dropdown-label-text">Personal tools</span> </label> <div class="vector-dropdown-content"> <div id="p-personal" class="vector-menu mw-portlet mw-portlet-personal user-links-collapsible-item" title="User menu" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-sitesupport" class="user-links-collapsible-item mw-list-item"><a href="https://donate.wikimedia.org/wiki/Special:FundraiserRedirector?utm_source=donate&utm_medium=sidebar&utm_campaign=C13_en.wikipedia.org&uselang=en"><span>Donate</span></a></li><li id="pt-createaccount" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:CreateAccount&returnto=String+literal" title="You are encouraged to create an account and log in; however, it is not mandatory"><span class="vector-icon mw-ui-icon-userAdd mw-ui-icon-wikimedia-userAdd"></span> <span>Create account</span></a></li><li id="pt-login" class="user-links-collapsible-item mw-list-item"><a href="/w/index.php?title=Special:UserLogin&returnto=String+literal" title="You're encouraged to log in; however, it's not mandatory. [o]" accesskey="o"><span class="vector-icon mw-ui-icon-logIn mw-ui-icon-wikimedia-logIn"></span> <span>Log in</span></a></li> </ul> </div> </div> <div id="p-user-menu-anon-editor" class="vector-menu mw-portlet mw-portlet-user-menu-anon-editor" > <div class="vector-menu-heading"> Pages for logged out editors <a href="/wiki/Help:Introduction" aria-label="Learn more about editing"><span>learn more</span></a> </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="pt-anoncontribs" class="mw-list-item"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [y]" accesskey="y"><span>Contributions</span></a></li><li id="pt-anontalk" class="mw-list-item"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [n]" accesskey="n"><span>Talk</span></a></li> </ul> </div> </div> </div> </div> </nav> </div> </header> </div> <div class="mw-page-container"> <div class="mw-page-container-inner"> <div class="vector-sitenotice-container"> <div id="siteNotice"><!-- CentralNotice --></div> </div> <div class="vector-column-start"> <div class="vector-main-menu-container"> <div id="mw-navigation"> <nav id="mw-panel" class="vector-main-menu-landmark" aria-label="Site"> <div id="vector-main-menu-pinned-container" class="vector-pinned-container"> </div> </nav> </div> </div> <div class="vector-sticky-pinned-container"> <nav id="mw-panel-toc" aria-label="Contents" data-event-name="ui.sidebar-toc" class="mw-table-of-contents-container vector-toc-landmark"> <div id="vector-toc-pinned-container" class="vector-pinned-container"> <div id="vector-toc" class="vector-toc vector-pinnable-element"> <div class="vector-pinnable-header vector-toc-pinnable-header vector-pinnable-header-pinned" data-feature-name="toc-pinned" data-pinnable-element-id="vector-toc" > <h2 class="vector-pinnable-header-label">Contents</h2> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-toc.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-toc.unpin">hide</button> </div> <ul class="vector-toc-contents" id="mw-panel-toc-list"> <li id="toc-mw-content-text" class="vector-toc-list-item vector-toc-level-1"> <a href="#" class="vector-toc-link"> <div class="vector-toc-text">(Top)</div> </a> </li> <li id="toc-Syntax" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Syntax"> <div class="vector-toc-text"> <span class="vector-toc-numb">1</span> <span>Syntax</span> </div> </a> <button aria-controls="toc-Syntax-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Syntax subsection</span> </button> <ul id="toc-Syntax-sublist" class="vector-toc-list"> <li id="toc-Bracketed_delimiters" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Bracketed_delimiters"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.1</span> <span>Bracketed delimiters</span> </div> </a> <ul id="toc-Bracketed_delimiters-sublist" class="vector-toc-list"> <li id="toc-Paired_delimiters" class="vector-toc-list-item vector-toc-level-3"> <a class="vector-toc-link" href="#Paired_delimiters"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.1.1</span> <span>Paired delimiters</span> </div> </a> <ul id="toc-Paired_delimiters-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Whitespace_delimiters" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Whitespace_delimiters"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.2</span> <span>Whitespace delimiters</span> </div> </a> <ul id="toc-Whitespace_delimiters-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-No_delimiters" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#No_delimiters"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.3</span> <span>No delimiters</span> </div> </a> <ul id="toc-No_delimiters-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Declarative_notation" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Declarative_notation"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.4</span> <span>Declarative notation</span> </div> </a> <ul id="toc-Declarative_notation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Constructor_functions" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Constructor_functions"> <div class="vector-toc-text"> <span class="vector-toc-numb">1.5</span> <span>Constructor functions</span> </div> </a> <ul id="toc-Constructor_functions-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Delimiter_collision" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Delimiter_collision"> <div class="vector-toc-text"> <span class="vector-toc-numb">2</span> <span>Delimiter collision</span> </div> </a> <button aria-controls="toc-Delimiter_collision-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Delimiter collision subsection</span> </button> <ul id="toc-Delimiter_collision-sublist" class="vector-toc-list"> <li id="toc-Doubling_up" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Doubling_up"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.1</span> <span>Doubling up</span> </div> </a> <ul id="toc-Doubling_up-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Dual_quoting" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Dual_quoting"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.2</span> <span>Dual quoting</span> </div> </a> <ul id="toc-Dual_quoting-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Delimiter_quoting" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Delimiter_quoting"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.3</span> <span>Delimiter quoting</span> </div> </a> <ul id="toc-Delimiter_quoting-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Multiple_quoting" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Multiple_quoting"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.4</span> <span>Multiple quoting</span> </div> </a> <ul id="toc-Multiple_quoting-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Constructor_functions_2" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Constructor_functions_2"> <div class="vector-toc-text"> <span class="vector-toc-numb">2.5</span> <span>Constructor functions</span> </div> </a> <ul id="toc-Constructor_functions_2-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Escape_sequences" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Escape_sequences"> <div class="vector-toc-text"> <span class="vector-toc-numb">3</span> <span>Escape sequences</span> </div> </a> <button aria-controls="toc-Escape_sequences-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle Escape sequences subsection</span> </button> <ul id="toc-Escape_sequences-sublist" class="vector-toc-list"> <li id="toc-Nested_escaping" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Nested_escaping"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.1</span> <span>Nested escaping</span> </div> </a> <ul id="toc-Nested_escaping-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Raw_strings" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Raw_strings"> <div class="vector-toc-text"> <span class="vector-toc-numb">3.2</span> <span>Raw strings</span> </div> </a> <ul id="toc-Raw_strings-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Multiline_string_literals" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Multiline_string_literals"> <div class="vector-toc-text"> <span class="vector-toc-numb">4</span> <span>Multiline string literals</span> </div> </a> <ul id="toc-Multiline_string_literals-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-String_literal_concatenation" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#String_literal_concatenation"> <div class="vector-toc-text"> <span class="vector-toc-numb">5</span> <span>String literal concatenation</span> </div> </a> <button aria-controls="toc-String_literal_concatenation-sublist" class="cdx-button cdx-button--weight-quiet cdx-button--icon-only vector-toc-toggle"> <span class="vector-icon mw-ui-icon-wikimedia-expand"></span> <span>Toggle String literal concatenation subsection</span> </button> <ul id="toc-String_literal_concatenation-sublist" class="vector-toc-list"> <li id="toc-Motivation" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Motivation"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.1</span> <span>Motivation</span> </div> </a> <ul id="toc-Motivation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Problems" class="vector-toc-list-item vector-toc-level-2"> <a class="vector-toc-link" href="#Problems"> <div class="vector-toc-text"> <span class="vector-toc-numb">5.2</span> <span>Problems</span> </div> </a> <ul id="toc-Problems-sublist" class="vector-toc-list"> </ul> </li> </ul> </li> <li id="toc-Different_kinds_of_strings" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Different_kinds_of_strings"> <div class="vector-toc-text"> <span class="vector-toc-numb">6</span> <span>Different kinds of strings</span> </div> </a> <ul id="toc-Different_kinds_of_strings-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-String_interpolation" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#String_interpolation"> <div class="vector-toc-text"> <span class="vector-toc-numb">7</span> <span>String interpolation</span> </div> </a> <ul id="toc-String_interpolation-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Embedding_source_code_in_string_literals" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Embedding_source_code_in_string_literals"> <div class="vector-toc-text"> <span class="vector-toc-numb">8</span> <span>Embedding source code in string literals</span> </div> </a> <ul id="toc-Embedding_source_code_in_string_literals-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-See_also" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#See_also"> <div class="vector-toc-text"> <span class="vector-toc-numb">9</span> <span>See also</span> </div> </a> <ul id="toc-See_also-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-Notes" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#Notes"> <div class="vector-toc-text"> <span class="vector-toc-numb">10</span> <span>Notes</span> </div> </a> <ul id="toc-Notes-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-References" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#References"> <div class="vector-toc-text"> <span class="vector-toc-numb">11</span> <span>References</span> </div> </a> <ul id="toc-References-sublist" class="vector-toc-list"> </ul> </li> <li id="toc-External_links" class="vector-toc-list-item vector-toc-level-1 vector-toc-list-item-expanded"> <a class="vector-toc-link" href="#External_links"> <div class="vector-toc-text"> <span class="vector-toc-numb">12</span> <span>External links</span> </div> </a> <ul id="toc-External_links-sublist" class="vector-toc-list"> </ul> </li> </ul> </div> </div> </nav> </div> </div> <div class="mw-content-container"> <main id="content" class="mw-body"> <header class="mw-body-header vector-page-titlebar"> <nav aria-label="Contents" class="vector-toc-landmark"> <div id="vector-page-titlebar-toc" class="vector-dropdown vector-page-titlebar-toc vector-button-flush-left" > <input type="checkbox" id="vector-page-titlebar-toc-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-titlebar-toc" class="vector-dropdown-checkbox " aria-label="Toggle the table of contents" > <label id="vector-page-titlebar-toc-label" for="vector-page-titlebar-toc-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--icon-only " aria-hidden="true" ><span class="vector-icon mw-ui-icon-listBullet mw-ui-icon-wikimedia-listBullet"></span> <span class="vector-dropdown-label-text">Toggle the table of contents</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-titlebar-toc-unpinned-container" class="vector-unpinned-container"> </div> </div> </div> </nav> <h1 id="firstHeading" class="firstHeading mw-first-heading"><span class="mw-page-title-main">String literal</span></h1> <div id="p-lang-btn" class="vector-dropdown mw-portlet mw-portlet-lang" > <input type="checkbox" id="p-lang-btn-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-p-lang-btn" class="vector-dropdown-checkbox mw-interlanguage-selector" aria-label="Go to an article in another language. Available in 3 languages" > <label id="p-lang-btn-label" for="p-lang-btn-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet cdx-button--action-progressive mw-portlet-lang-heading-3" aria-hidden="true" ><span class="vector-icon mw-ui-icon-language-progressive mw-ui-icon-wikimedia-language-progressive"></span> <span class="vector-dropdown-label-text">3 languages</span> </label> <div class="vector-dropdown-content"> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li class="interlanguage-link interwiki-ar mw-list-item"><a href="https://ar.wikipedia.org/wiki/%D8%AD%D8%B1%D9%81%D9%8A%D8%A7%D8%AA_%D8%A7%D9%84%D8%B3%D9%84%D8%A7%D8%B3%D9%84_%D8%A7%D9%84%D9%86%D8%B5%D9%8A%D8%A9" title="حرفيات السلاسل النصية – Arabic" lang="ar" hreflang="ar" data-title="حرفيات السلاسل النصية" data-language-autonym="العربية" data-language-local-name="Arabic" class="interlanguage-link-target"><span>العربية</span></a></li><li class="interlanguage-link interwiki-kk mw-list-item"><a href="https://kk.wikipedia.org/wiki/%D0%91%D0%B5%D0%B4%D0%B5%D1%80%D0%B1%D0%B5%D0%BB%D0%B3%D1%96%D0%BB%D1%96%D0%BA_%D1%82%D1%96%D0%B7%D0%B1%D0%B5%D0%BA%D1%88%D0%B5" title="Бедербелгілік тізбекше – Kazakh" lang="kk" hreflang="kk" data-title="Бедербелгілік тізбекше" data-language-autonym="Қазақша" data-language-local-name="Kazakh" class="interlanguage-link-target"><span>Қазақша</span></a></li><li class="interlanguage-link interwiki-pl mw-list-item"><a href="https://pl.wikipedia.org/wiki/Litera%C5%82_%C5%82a%C5%84cuchowy" title="Literał łańcuchowy – Polish" lang="pl" hreflang="pl" data-title="Literał łańcuchowy" data-language-autonym="Polski" data-language-local-name="Polish" class="interlanguage-link-target"><span>Polski</span></a></li> </ul> <div class="after-portlet after-portlet-lang"><span class="wb-langlinks-edit wb-langlinks-link"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q4736519#sitelinks-wikipedia" title="Edit interlanguage links" class="wbc-editpage">Edit links</a></span></div> </div> </div> </div> </header> <div class="vector-page-toolbar"> <div class="vector-page-toolbar-container"> <div id="left-navigation"> <nav aria-label="Namespaces"> <div id="p-associated-pages" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-associated-pages" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-nstab-main" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/String_literal" title="View the content page [c]" accesskey="c"><span>Article</span></a></li><li id="ca-talk" class="vector-tab-noicon mw-list-item"><a href="/wiki/Talk:String_literal" rel="discussion" title="Discuss improvements to the content page [t]" accesskey="t"><span>Talk</span></a></li> </ul> </div> </div> <div id="vector-variants-dropdown" class="vector-dropdown emptyPortlet" > <input type="checkbox" id="vector-variants-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-variants-dropdown" class="vector-dropdown-checkbox " aria-label="Change language variant" > <label id="vector-variants-dropdown-label" for="vector-variants-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">English</span> </label> <div class="vector-dropdown-content"> <div id="p-variants" class="vector-menu mw-portlet mw-portlet-variants emptyPortlet" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> </ul> </div> </div> </div> </div> </nav> </div> <div id="right-navigation" class="vector-collapsible"> <nav aria-label="Views"> <div id="p-views" class="vector-menu vector-menu-tabs mw-portlet mw-portlet-views" > <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-view" class="selected vector-tab-noicon mw-list-item"><a href="/wiki/String_literal"><span>Read</span></a></li><li id="ca-edit" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=String_literal&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-history" class="vector-tab-noicon mw-list-item"><a href="/w/index.php?title=String_literal&action=history" title="Past revisions of this page [h]" accesskey="h"><span>View history</span></a></li> </ul> </div> </div> </nav> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-dropdown" class="vector-dropdown vector-page-tools-dropdown" > <input type="checkbox" id="vector-page-tools-dropdown-checkbox" role="button" aria-haspopup="true" data-event-name="ui.dropdown-vector-page-tools-dropdown" class="vector-dropdown-checkbox " aria-label="Tools" > <label id="vector-page-tools-dropdown-label" for="vector-page-tools-dropdown-checkbox" class="vector-dropdown-label cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--weight-quiet" aria-hidden="true" ><span class="vector-dropdown-label-text">Tools</span> </label> <div class="vector-dropdown-content"> <div id="vector-page-tools-unpinned-container" class="vector-unpinned-container"> <div id="vector-page-tools" class="vector-page-tools vector-pinnable-element"> <div class="vector-pinnable-header vector-page-tools-pinnable-header vector-pinnable-header-unpinned" data-feature-name="page-tools-pinned" data-pinnable-element-id="vector-page-tools" data-pinned-container-id="vector-page-tools-pinned-container" data-unpinned-container-id="vector-page-tools-unpinned-container" > <div class="vector-pinnable-header-label">Tools</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-page-tools.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-page-tools.unpin">hide</button> </div> <div id="p-cactions" class="vector-menu mw-portlet mw-portlet-cactions emptyPortlet vector-has-collapsible-items" title="More options" > <div class="vector-menu-heading"> Actions </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="ca-more-view" class="selected vector-more-collapsible-item mw-list-item"><a href="/wiki/String_literal"><span>Read</span></a></li><li id="ca-more-edit" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=String_literal&action=edit" title="Edit this page [e]" accesskey="e"><span>Edit</span></a></li><li id="ca-more-history" class="vector-more-collapsible-item mw-list-item"><a href="/w/index.php?title=String_literal&action=history"><span>View history</span></a></li> </ul> </div> </div> <div id="p-tb" class="vector-menu mw-portlet mw-portlet-tb" > <div class="vector-menu-heading"> General </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-whatlinkshere" class="mw-list-item"><a href="/wiki/Special:WhatLinksHere/String_literal" title="List of all English Wikipedia pages containing links to this page [j]" accesskey="j"><span>What links here</span></a></li><li id="t-recentchangeslinked" class="mw-list-item"><a href="/wiki/Special:RecentChangesLinked/String_literal" rel="nofollow" title="Recent changes in pages linked from this page [k]" accesskey="k"><span>Related changes</span></a></li><li id="t-upload" class="mw-list-item"><a href="/wiki/Wikipedia:File_Upload_Wizard" title="Upload files [u]" accesskey="u"><span>Upload file</span></a></li><li id="t-specialpages" class="mw-list-item"><a href="/wiki/Special:SpecialPages" title="A list of all special pages [q]" accesskey="q"><span>Special pages</span></a></li><li id="t-permalink" class="mw-list-item"><a href="/w/index.php?title=String_literal&oldid=1254523808" title="Permanent link to this revision of this page"><span>Permanent link</span></a></li><li id="t-info" class="mw-list-item"><a href="/w/index.php?title=String_literal&action=info" title="More information about this page"><span>Page information</span></a></li><li id="t-cite" class="mw-list-item"><a href="/w/index.php?title=Special:CiteThisPage&page=String_literal&id=1254523808&wpFormIdentifier=titleform" title="Information on how to cite this page"><span>Cite this page</span></a></li><li id="t-urlshortener" class="mw-list-item"><a href="/w/index.php?title=Special:UrlShortener&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FString_literal"><span>Get shortened URL</span></a></li><li id="t-urlshortener-qrcode" class="mw-list-item"><a href="/w/index.php?title=Special:QrCode&url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FString_literal"><span>Download QR code</span></a></li> </ul> </div> </div> <div id="p-coll-print_export" class="vector-menu mw-portlet mw-portlet-coll-print_export" > <div class="vector-menu-heading"> Print/export </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="coll-download-as-rl" class="mw-list-item"><a href="/w/index.php?title=Special:DownloadAsPdf&page=String_literal&action=show-download-screen" title="Download this page as a PDF file"><span>Download as PDF</span></a></li><li id="t-print" class="mw-list-item"><a href="/w/index.php?title=String_literal&printable=yes" title="Printable version of this page [p]" accesskey="p"><span>Printable version</span></a></li> </ul> </div> </div> <div id="p-wikibase-otherprojects" class="vector-menu mw-portlet mw-portlet-wikibase-otherprojects" > <div class="vector-menu-heading"> In other projects </div> <div class="vector-menu-content"> <ul class="vector-menu-content-list"> <li id="t-wikibase" class="wb-otherproject-link wb-otherproject-wikibase-dataitem mw-list-item"><a href="https://www.wikidata.org/wiki/Special:EntityPage/Q4736519" title="Structured data on this page hosted by Wikidata [g]" accesskey="g"><span>Wikidata item</span></a></li> </ul> </div> </div> </div> </div> </div> </div> </nav> </div> </div> </div> <div class="vector-column-end"> <div class="vector-sticky-pinned-container"> <nav class="vector-page-tools-landmark" aria-label="Page tools"> <div id="vector-page-tools-pinned-container" class="vector-pinned-container"> </div> </nav> <nav class="vector-appearance-landmark" aria-label="Appearance"> <div id="vector-appearance-pinned-container" class="vector-pinned-container"> <div id="vector-appearance" class="vector-appearance vector-pinnable-element"> <div class="vector-pinnable-header vector-appearance-pinnable-header vector-pinnable-header-pinned" data-feature-name="appearance-pinned" data-pinnable-element-id="vector-appearance" data-pinned-container-id="vector-appearance-pinned-container" data-unpinned-container-id="vector-appearance-unpinned-container" > <div class="vector-pinnable-header-label">Appearance</div> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-pin-button" data-event-name="pinnable-header.vector-appearance.pin">move to sidebar</button> <button class="vector-pinnable-header-toggle-button vector-pinnable-header-unpin-button" data-event-name="pinnable-header.vector-appearance.unpin">hide</button> </div> </div> </div> </nav> </div> </div> <div id="bodyContent" class="vector-body" aria-labelledby="firstHeading" data-mw-ve-target-container> <div class="vector-body-before-content"> <div class="mw-indicators"> </div> <div id="siteSub" class="noprint">From Wikipedia, the free encyclopedia</div> </div> <div id="contentSub"><div id="mw-content-subtitle"><span class="mw-redirectedfrom">(Redirected from <a href="/w/index.php?title=Literal_string&redirect=no" class="mw-redirect" title="Literal string">Literal string</a>)</span></div></div> <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><div class="shortdescription nomobile noexcerpt noprint searchaux" style="display:none">Notation for representing a string in source code</div> <p>A <b>string literal</b> or <b>anonymous string</b> is a <a href="/wiki/Literal_(computer_programming)" title="Literal (computer programming)">literal</a> for a string value in the source code of a computer program. Modern programming languages commonly use a quoted sequence of characters, formally "bracketed delimiters", as in <code>x = "foo"</code>, where , <code>"foo"</code> is a string literal with value <code>foo</code>. Methods such as escape sequences can be used to avoid the problem of delimiter collision (issues with brackets) and allow the delimiters to be embedded in a string. There are many alternate notations for specifying string literals especially in complicated cases. The exact notation depends on the programming language in question. Nevertheless, there are general guidelines that most modern programming languages follow. </p> <meta property="mw:PageProp/toc" /> <div class="mw-heading mw-heading2"><h2 id="Syntax">Syntax</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=1" title="Edit section: Syntax"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <div class="mw-heading mw-heading3"><h3 id="Bracketed_delimiters">Bracketed delimiters</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=2" title="Edit section: Bracketed delimiters"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Most modern programming languages use <a href="/wiki/Delimiter#Bracket_delimiters" title="Delimiter">bracket delimiters</a> (also <b>balanced delimiters</b>) to specify string literals. <a href="/wiki/Quotation_mark" title="Quotation mark">Double quotations</a> are the most common quoting delimiters used: </p> <pre> "Hi There!" </pre> <p>An <a href="/wiki/Empty_string" title="Empty string">empty string</a> is literally written by a pair of quotes with no character at all in between: </p> <pre> "" </pre> <p>Some languages either allow or mandate the use of single quotations instead of double quotations (the string must begin and end with the same kind of quotation mark and the type of quotation mark may or may not give slightly different semantics): </p> <pre> 'Hi There!' </pre> <p>These quotation marks are <i>unpaired</i> (the same character is used as an opener and a closer), which is a hangover from the <a href="/wiki/Typewriter" title="Typewriter">typewriter</a> technology which was the precursor of the earliest computer input and output devices. </p><p>In terms of <a href="/wiki/Regular_expression" title="Regular expression">regular expressions</a>, a basic quoted string literal is given as: </p> <pre>"[^"]*" </pre> <p>This means that a string literal is written as: <i>a quote, followed by zero, one, or more non-quote characters, followed by a quote</i>. In practice this is often complicated by escaping, other delimiters, and excluding newlines. </p> <div class="mw-heading mw-heading4"><h4 id="Paired_delimiters">Paired delimiters</h4><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=3" title="Edit section: Paired delimiters"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A number of languages provide for paired delimiters, where the opening and closing delimiters are different. These also often allow nested strings, so delimiters can be embedded, so long as they are paired, but still result in delimiter collision for embedding an unpaired closing delimiter. Examples include <a href="/wiki/PostScript" title="PostScript">PostScript</a>, which uses parentheses, as in <code>(The quick (brown fox))</code> and <a href="/wiki/M4_(computer_language)" title="M4 (computer language)">m4</a>, which uses the <a href="/wiki/Backtick" title="Backtick">backtick</a> (`) as the starting delimiter, and the <a href="/wiki/Apostrophe" title="Apostrophe">apostrophe</a> (') as the ending delimiter. <a href="/wiki/Tcl" title="Tcl">Tcl</a> allows both quotes (for interpolated strings) and braces (for raw strings), as in <code>"The quick brown fox"</code> or <code>{The quick {brown fox}}</code>; this derives from the single quotations in Unix shells and the use of braces in <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> for compound statements, since blocks of code is in Tcl syntactically the same thing as string literals – that the delimiters are paired is essential for making this feasible. </p><p>The <a href="/wiki/Unicode" title="Unicode">Unicode</a> character set includes paired (separate opening and closing) versions of both single and double quotations: </p> <pre> “Hi There!” ‘Hi There!’ „Hi There!“ «Hi There!» </pre> <p>These, however, are rarely used, as many programming languages will not register them (one exception is the paired double quotations which can be used in <a href="/wiki/Visual_Basic_.NET" class="mw-redirect" title="Visual Basic .NET">Visual Basic .NET</a>). Unpaired marks are preferred for compatibility, as they are easier to type on a wide range of keyboards, and so even in languages where they are permitted, many projects forbid their use for source code. </p> <div class="mw-heading mw-heading3"><h3 id="Whitespace_delimiters">Whitespace delimiters</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=4" title="Edit section: Whitespace delimiters"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>String literals might be ended by newlines. </p><p>One example is <a href="/wiki/MediaWiki" title="MediaWiki">MediaWiki</a> template parameters. </p> <pre> {{Navbox |name=Nulls |title=[[wikt:Null|Nulls]] in [[computing]] }}</pre> <p>There might be special syntax for multi-line strings. </p><p>In <a href="/wiki/YAML" title="YAML">YAML</a>, string literals may be specified by the relative positioning of <a href="/wiki/Whitespace_character" title="Whitespace character">whitespace</a> and indentation. </p> <div class="mw-highlight mw-highlight-lang-yaml mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">title</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">An example multi-line string in YAML</span> <span class="w"> </span><span class="nt">body </span><span class="p">:</span><span class="w"> </span><span class="p p-Indicator">|</span> <span class="w"> </span><span class="no">This is a multi-line string.</span> <span class="w"> </span><span class="no">"special" metacharacters may</span> <span class="w"> </span><span class="no">appear here. The extent of this string is</span> <span class="w"> </span><span class="no">represented by indentation.</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="No_delimiters">No delimiters</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=5" title="Edit section: No delimiters"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some programming languages, such as Perl and PHP, allow string literals without any delimiters in some contexts. In the following Perl program, for example, <code>red</code>, <code>green</code>, and <code>blue</code> are string literals, but are unquoted: </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">%map</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">red</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="mh">0x00f</span><span class="p">,</span><span class="w"> </span><span class="n">blue</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="mh">0x0f0</span><span class="p">,</span><span class="w"> </span><span class="n">green</span><span class="w"> </span><span class="o">=></span><span class="w"> </span><span class="mh">0xf00</span><span class="p">);</span> </pre></div> <p>Perl treats non-reserved sequences of alphanumeric characters as string literals in most contexts. For example, the following two lines of Perl are equivalent: </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"x"</span><span class="p">;</span> <span class="nv">$y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="p">;</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Declarative_notation">Declarative notation</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=6" title="Edit section: Declarative notation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In the original <a href="/wiki/FORTRAN" class="mw-redirect" title="FORTRAN">FORTRAN</a> programming language (for example), string literals were written in so-called <a href="/wiki/Hollerith_constant" title="Hollerith constant"><i>Hollerith</i> notation</a>, where a decimal count of the number of characters was followed by the letter H, and then the characters of the string: </p> <div class="mw-highlight mw-highlight-lang-fortran mw-content-ltr" dir="ltr"><pre><span></span><span class="mi">35</span><span class="n">HAn</span><span class="w"> </span><span class="n">example</span><span class="w"> </span><span class="n">Hollerith</span><span class="w"> </span><span class="n">string</span><span class="w"> </span><span class="n">literal</span> </pre></div> <p>This declarative notation style is contrasted with bracketed <a href="/wiki/Delimiter" title="Delimiter">delimiter</a> quoting, because it does not require the use of balanced "bracketed" characters on either side of the string. </p><p><b>Advantages:</b> </p> <ul><li>eliminates text searching (for the delimiter character) and therefore requires significantly less <a href="/wiki/Computational_overhead" class="mw-redirect" title="Computational overhead">overhead</a></li> <li>avoids the problem of <a href="/wiki/Delimiter_collision" class="mw-redirect" title="Delimiter collision">delimiter collision</a></li> <li>enables the inclusion of <a href="/wiki/Metacharacter" title="Metacharacter">metacharacters</a> that might otherwise be mistaken as commands</li> <li>can be used for quite effective data compression of plain text strings<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="doesn't look like compression to me (March 2011)">citation needed</span></a></i>]</sup></li></ul> <p><b>Drawbacks:</b> </p> <ul><li>this type of notation is error-prone if used as manual entry by <a href="/wiki/Programmer" title="Programmer">programmers</a></li> <li>special care is needed in case of multi byte encodings</li></ul> <p>This is however not a drawback when the prefix is generated by an algorithm as is most likely the case.<sup class="noprint Inline-Template Template-Fact" style="white-space:nowrap;">[<i><a href="/wiki/Wikipedia:Citation_needed" title="Wikipedia:Citation needed"><span title="humans don't generally write Fortran code, or what? we're talking source code formats, after all... (February 2012)">citation needed</span></a></i>]</sup> </p> <div class="mw-heading mw-heading3"><h3 id="Constructor_functions">Constructor functions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=7" title="Edit section: Constructor functions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>C++ has two styles of string, one inherited from C (delimited by <code>"</code>), and the safer <code>std::string</code> in the C++ Standard Library. The <code>std::string</code> class is frequently used in the same way a string literal would be used in other languages, and is often preferred to C-style strings for its greater flexibility and safety. But it comes with a performance penalty for string literals, as <code>std::string</code> usually allocates memory dynamically, and must copy the C-style string literal to it at run time. </p><p>Before C++11, there was no literal for C++ strings (C++11 allows <code>"this is a C++ string"s</code> with the <code>s</code> at the end of the literal), so the normal constructor syntax was used, for example: </p> <ul><li><code>std::string str = "initializer syntax";</code></li> <li><code>std::string str("converting constructor syntax");</code></li> <li><code>std::string str = string("explicit constructor syntax");</code></li></ul> <p>all of which have the same interpretation. Since C++11, there is also new constructor syntax: </p> <ul><li><code>std::string str{"uniform initializer syntax"};</code></li> <li><code>auto str = "constexpr literal syntax"s;</code></li></ul> <div class="mw-heading mw-heading2"><h2 id="Delimiter_collision">Delimiter collision</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=8" title="Edit section: Delimiter collision"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1236090951">.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}</style><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Delimiter_collision" class="mw-redirect" title="Delimiter collision">Delimiter collision</a></div> <p>When using quoting, if one wishes to represent the delimiter itself in a string literal, one runs into the problem of <i><a href="/wiki/Delimiter_collision" class="mw-redirect" title="Delimiter collision">delimiter collision</a>.</i> For example, if the delimiter is a double quote, one cannot simply represent a double quote itself by the literal <code>"""</code> as the second quote is interpreted as the end of the string literal, not as the value of the string, and similarly one cannot write <code>"This is "in quotes", but invalid."</code> as the middle quoted portion is instead interpreted as outside of quotes. There are various solutions, the most general-purpose of which is using escape sequences, such as <code>"\""</code> or <code>"This is \"in quotes\" and properly escaped."</code>, but there are many other solutions. </p><p>Paired quotes, such as braces in Tcl, allow nested strings, such as <code>{foo {bar} zork}</code> but do not otherwise solve the problem of delimiter collision, since an unbalanced closing delimiter cannot simply be included, as in <code>{}}</code>. </p> <div class="mw-heading mw-heading3"><h3 id="Doubling_up">Doubling up</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=9" title="Edit section: Doubling up"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A number of languages, including <a href="/wiki/Pascal_(programming_language)" title="Pascal (programming language)">Pascal</a>, <a href="/wiki/BASIC" title="BASIC">BASIC</a>, <a href="/wiki/DIGITAL_Command_Language" title="DIGITAL Command Language">DCL</a>, <a href="/wiki/Smalltalk" title="Smalltalk">Smalltalk</a>, <a href="/wiki/SQL" title="SQL">SQL</a>, <a href="/wiki/J_(programming_language)" title="J (programming language)">J</a>, and <a href="/wiki/Fortran" title="Fortran">Fortran</a>, avoid delimiter collision by <i>doubling up</i> on the quotation marks that are intended to be part of the string literal itself: </p> <div class="mw-highlight mw-highlight-lang-pascal mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="s">'This Pascal string</span><span class="se">''</span><span class="s">contains two apostrophes</span><span class="se">''</span><span class="s">'</span> </pre></div> <div class="mw-highlight mw-highlight-lang-qbasic mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="s2">"I said, ""Can you hear me?"""</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Dual_quoting">Dual quoting</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=10" title="Edit section: Dual quoting"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some languages, such as <a href="/wiki/Fortran" title="Fortran">Fortran</a>, <a href="/wiki/Modula-2" title="Modula-2">Modula-2</a>, <a href="/wiki/JavaScript" title="JavaScript">JavaScript</a>, <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>, and <a href="/wiki/PHP" title="PHP">PHP</a> allow more than one quoting delimiter; in the case of two possible delimiters, this is known as <b>dual quoting</b>. Typically, this consists of allowing the programmer to use either single quotations or double quotations interchangeably – each literal must use one or the other. </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span> <span class="s2">"This is John's apple."</span> <span class="s1">'I said, "Can you hear me?"'</span> </pre></div> <p>This does not allow having a single literal with both delimiters in it, however. This can be worked around by using several literals and using <a href="/wiki/String_concatenation" class="mw-redirect" title="String concatenation">string concatenation</a>: </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span> <span class="s1">'I said, "This is '</span> <span class="o">+</span> <span class="s2">"John's"</span> <span class="o">+</span> <span class="s1">' apple."'</span> </pre></div> <p>Python has <a href="/wiki/String_literal_concatenation" class="mw-redirect" title="String literal concatenation">string literal concatenation</a>, so consecutive string literals are concatenated even without an operator, so this can be reduced to: </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span> <span class="s1">'I said, "This is '</span><span class="s2">"John's"</span><span class="s1">' apple."'</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Delimiter_quoting">Delimiter quoting</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=11" title="Edit section: Delimiter quoting"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p><a href="/wiki/C%2B%2B11" title="C++11">C++11</a> introduced so-called <i>raw string literals</i>. They consist, essentially of </p> <dl><dd><code>R"</code> <i>end-of-string-id</i> <code>(</code> <i>content</i> <code>)</code> <i>end-of-string-id</i> <code>"</code>,</dd></dl> <p>that is, after <code>R"</code> the programmer can enter up to 16 characters except whitespace characters, parentheses, or backslash, which form the <i>end-of-string-id</i> (its purpose is to be repeated to signal the end of the string, <i>eos id</i> for short), then an opening parenthesis (to denote the end of the eos id) is required. Then follows the actual content of the literal: Any sequence characters may be used (except that it may not contain a closing parenthesis followed by the eos id followed a quote), and finally – to terminate the string – a closing parenthesis, the eos id, and a quote is required.<br /> The simplest case of such a literal is with empty content and empty eos id: <code>R"()"</code>.<br /> The eos id may itself contain quotes: <code>R""(I asked, "Can you hear me?")""</code> is a valid literal (the eos id is <code>"</code> here.)<br /> Escape sequences don't work in raw string literals. </p><p><a href="/wiki/D_(programming_language)" title="D (programming language)">D</a> supports a few quoting delimiters, with such strings starting with <code>q"</code> plus an opening delimiter and ending with the respective closing delimiter and <code>"</code>. Available delimiter pairs are <code>()</code>, <code><></code>, <code>{}</code>, and <code>[]</code>; an unpaired non-identifier delimiter is its own closing delimiter. The paired delimiters nest, so that <code>q"(A pair "()" of parens in quotes)"</code> is a valid literal; an example with the non-nesting <code>/</code> character is <code>q"/I asked, "Can you hear me?"/"</code>.<br /> Similar to C++11, D allows here-document-style literals with end-of-string ids: </p> <dl><dd><code>q"</code> <i>end-of-string-id</i> newline <i>content</i> newline <i>end-of-string-id</i> <code>"</code></dd></dl> <p>In D, the <i>end-of-string-id</i> must be an identifier (alphanumeric characters). </p><p>In some programming languages, such as <a href="/wiki/Bourne_shell" title="Bourne shell">sh</a> and <a href="/wiki/Perl" title="Perl">Perl</a>, there are different delimiters that are treated differently, such as doing string interpolation or not, and thus care must be taken when choosing which delimiter to use; see <a href="#Different_kinds_of_strings">different kinds of strings</a>, below. </p> <div class="mw-heading mw-heading3"><h3 id="Multiple_quoting">Multiple quoting</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=12" title="Edit section: Multiple quoting"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A further extension is the use of <i>multiple quoting</i>, which allows the author to choose which characters should specify the bounds of a string literal. </p><p>For example, in <a href="/wiki/Perl" title="Perl">Perl</a>: </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="sx">qq^I said, "Can you hear me?"^</span> <span class="sx">qq@I said, "Can you hear me?"@</span> <span class="sx">qq§I said, "Can you hear me?"§</span> </pre></div> <p>all produce the desired result. Although this notation is more flexible, few languages support it; other than Perl, <a href="/wiki/Ruby_(programming_language)" title="Ruby (programming language)">Ruby</a> (influenced by Perl) and <a href="/wiki/C%2B%2B11" title="C++11">C++11</a> also support these. A variant of multiple quoting is the use of <a href="/wiki/Here_document" title="Here document">here document</a>-style strings. </p><p>Lua (as of 5.1) provides a limited form of multiple quoting, particularly to allow nesting of long comments or embedded strings. Normally one uses <code>[[</code> and <code>]]</code> to delimit literal strings (initial newline stripped, otherwise raw), but the opening brackets can include any number of equal signs, and only closing brackets with the same number of signs close the string. For example: </p> <div class="mw-highlight mw-highlight-lang-lua mw-content-ltr" dir="ltr"><pre><span></span><span class="kd">local</span> <span class="n">ls</span> <span class="o">=</span> <span class="s">[=[</span> <span class="s">This notation can be used for Windows paths: </span> <span class="s">local path = [[C:\Windows\Fonts]]</span> <span class="s">]=]</span> </pre></div> <p>Multiple quoting is particularly useful with <a href="/wiki/Regular_expression" title="Regular expression">regular expressions</a> that contain usual delimiters such as quotes, as this avoids needing to escape them. An early example is <a href="/wiki/Sed" title="Sed">sed</a>, where in the substitution command <code>s/<b>regex</b>/<b>replacement</b>/</code> the default slash <code>/</code> delimiters can be replaced by another character, as in <code>s,<b>regex</b>,<b>replacement</b>,</code> . </p> <div class="mw-heading mw-heading3"><h3 id="Constructor_functions_2">Constructor functions</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=13" title="Edit section: Constructor functions"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Another option, which is rarely used in modern languages, is to use a function to construct a string, rather than representing it via a literal. This is generally not used in modern languages because the computation is done at run time, rather than at parse time. </p><p>For example, early forms of <a href="/wiki/BASIC" title="BASIC">BASIC</a> did not include escape sequences or any other workarounds listed here, and thus one instead was required to use the <code>CHR$</code> function, which returns a string containing the character corresponding to its argument. In <a href="/wiki/ASCII" title="ASCII">ASCII</a> the quotation mark has the value 34, so to represent a string with quotes on an ASCII system one would write </p> <div class="mw-highlight mw-highlight-lang-qbasic mw-content-ltr" dir="ltr"><pre><span></span><span class="s2">"I said, "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="kr">CHR$</span><span class="p">(</span><span class="il">34</span><span class="p">)</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s2">"Can you hear me?"</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="kr">CHR$</span><span class="p">(</span><span class="il">34</span><span class="p">)</span> </pre></div> <p>In C, a similar facility is available via <code><a href="/wiki/Sprintf" class="mw-redirect" title="Sprintf">sprintf</a></code> and the <code>%c</code> "character" format specifier, though in the presence of other workarounds this is generally not used: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">char</span><span class="w"> </span><span class="n">buffer</span><span class="p">[</span><span class="mi">32</span><span class="p">];</span> <span class="n">snprintf</span><span class="p">(</span><span class="n">buffer</span><span class="p">,</span><span class="w"> </span><span class="k">sizeof</span><span class="w"> </span><span class="n">buffer</span><span class="p">,</span><span class="w"> </span><span class="s">"This is %cin quotes.%c"</span><span class="p">,</span><span class="w"> </span><span class="mi">34</span><span class="p">,</span><span class="w"> </span><span class="mi">34</span><span class="p">);</span> </pre></div> <p>These constructor functions can also be used to represent nonprinting characters, though escape sequences are generally used instead. A similar technique can be used in C++ with the <code>std::string</code> stringification operator. </p> <div class="mw-heading mw-heading2"><h2 id="Escape_sequences">Escape sequences</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=14" title="Edit section: Escape sequences"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951"><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/Escape_sequence" title="Escape sequence">Escape sequence</a></div> <p>Escape sequences are a general technique for representing characters that are otherwise difficult to represent directly, including delimiters, nonprinting characters (such as backspaces), newlines, and whitespace characters (which are otherwise impossible to distinguish visually), and have a long history. They are accordingly widely used in string literals, and adding an escape sequence (either to a single character or throughout a string) is known as <b>escaping</b>. </p><p>One character is chosen as a prefix to give encodings for characters that are difficult or impossible to include directly. Most commonly this is <a href="/wiki/Backslash" title="Backslash">backslash</a>; in addition to other characters, a key point is that backslash itself can be encoded as a double backslash <code>\\</code> and for delimited strings the delimiter itself can be encoded by escaping, say by <code>\"</code> for ". A regular expression for such escaped strings can be given as follows, as found in the <a href="/wiki/ANSI_C" title="ANSI C">ANSI C</a> specification:<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>a<span class="cite-bracket">]</span></a></sup> </p> <pre>"(\\.|[^\\"])*"</pre> <p>meaning "a quote; followed by zero or more of either an escaped character (backslash followed by something, possibly backslash or quote), or a non-escape, non-quote character; ending in a quote" – the only issue is distinguishing the terminating quote from a quote preceded by a backslash, which may itself be escaped. Multiple characters can follow the backslash, such as <code>\uFFFF</code>, depending on the escaping scheme. </p><p>An escaped string must then itself be <a href="/wiki/Lexical_analysis" title="Lexical analysis">lexically analyzed</a>, converting the escaped string into the unescaped string that it represents. This is done during the evaluation phase of the overall lexing of the computer language: the evaluator of the lexer of the overall language executes its own lexer for escaped string literals. </p><p>Among other things, it must be possible to encode the character that normally terminates the string constant, plus there must be some way to specify the escape character itself. Escape sequences are not always pretty or easy to use, so many compilers also offer other means of solving the common problems. Escape sequences, however, solve every delimiter problem and most compilers interpret escape sequences. When an escape character is inside a string literal, it means "this is the start of the escape sequence". Every escape sequence specifies one character which is to be placed directly into the string. The actual number of characters required in an escape sequence varies. The escape character is on the top/left of the keyboard, but the editor will translate it, therefore it is not directly tapeable into a string. The backslash is used to represent the escape character in a string literal. </p><p>Many languages support the use of <a href="/wiki/Metacharacter" title="Metacharacter">metacharacters</a> inside string literals. Metacharacters have varying interpretations depending on the context and language, but are generally a kind of 'processing command' for representing printing or nonprinting characters. </p><p>For instance, in a <a href="/wiki/C_string_handling" title="C string handling">C string</a> literal, if the backslash is followed by a letter such as "b", "n" or "t", then this represents a nonprinting <i>backspace</i>, <i>newline</i> or <i>tab</i> character respectively. Or if the backslash is followed by 1-3 <a href="/wiki/Octal" title="Octal">octal</a> digits, then this sequence is interpreted as representing the arbitrary code unit with the specified value in the literal's encoding (for example, the corresponding <a href="/wiki/ASCII" title="ASCII">ASCII</a> code for an ASCII literal). This was later extended to allow more modern <a href="/wiki/Hexadecimal" title="Hexadecimal">hexadecimal</a> character code notation: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="s">"I said,</span><span class="se">\t\t\x22Ca</span><span class="s">n you hear me?</span><span class="se">\x22\n</span><span class="s">"</span> </pre></div> <table class="wikitable"> <tbody><tr> <th>Escape Sequence</th> <th>Unicode</th> <th>Literal Characters placed into string </th></tr> <tr> <td>\0</td> <td>U+0000</td> <td><a href="/wiki/Null_character" title="Null character">null character</a><sup id="cite_ref-haskell_3-0" class="reference"><a href="#cite_note-haskell-3"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-javascript_4-0" class="reference"><a href="#cite_note-javascript-4"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><br />(typically as a special case of \ooo octal notation) </td></tr> <tr> <td>\a</td> <td>U+0007</td> <td>alert<sup id="cite_ref-msdn_5-0" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Rationale_2003_C_6-0" class="reference"><a href="#cite_note-Rationale_2003_C-6"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\b</td> <td>U+0008</td> <td>backspace<sup id="cite_ref-msdn_5-1" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\f</td> <td>U+000C</td> <td>form feed<sup id="cite_ref-msdn_5-2" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\n</td> <td>U+000A</td> <td>line feed<sup id="cite_ref-msdn_5-3" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> (or newline in POSIX) </td></tr> <tr> <td>\r</td> <td>U+000D</td> <td>carriage return<sup id="cite_ref-msdn_5-4" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> (or newline in Mac OS 9 and earlier) </td></tr> <tr> <td>\t</td> <td>U+0009</td> <td>horizontal tab<sup id="cite_ref-msdn_5-5" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\v</td> <td>U+000B</td> <td>vertical tab<sup id="cite_ref-msdn_5-6" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\e</td> <td>U+001B</td> <td><a href="/wiki/Escape_character" title="Escape character">escape character</a><sup id="cite_ref-Rationale_2003_C_6-1" class="reference"><a href="#cite_note-Rationale_2003_C-6"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> (<a href="/wiki/GNU_Compiler_Collection" title="GNU Compiler Collection">GCC</a>,<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> <a href="/wiki/Clang" title="Clang">clang</a> and <a href="/wiki/Tiny_C_Compiler" title="Tiny C Compiler">tcc</a>) </td></tr> <tr> <td>\u####</td> <td>U+####</td> <td>16-bit <a href="/wiki/Unicode" title="Unicode">Unicode</a> character where #### are four hex digits<sup id="cite_ref-javascript_4-1" class="reference"><a href="#cite_note-javascript-4"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\U########</td> <td>U+######</td> <td>32-bit Unicode character where ######## are eight hex digits (Unicode character space is currently only 21 bits wide, so the first two hex digits will always be zero) </td></tr> <tr> <td>\u{######}</td> <td>U+######</td> <td>21-bit Unicode character where ###### is a variable number of hex digits </td></tr> <tr> <td>\x##</td> <td>Depends on encoding<sup id="cite_ref-encoding_8-0" class="reference"><a href="#cite_note-encoding-8"><span class="cite-bracket">[</span>b<span class="cite-bracket">]</span></a></sup></td> <td>8-bit character specification where # is a hex digit. The length of a hex escape sequence is not limited to two digits, instead being of an arbitrary length.<sup id="cite_ref-msdn_5-7" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\ooo</td> <td>Depends on encoding<sup id="cite_ref-encoding_8-1" class="reference"><a href="#cite_note-encoding-8"><span class="cite-bracket">[</span>b<span class="cite-bracket">]</span></a></sup></td> <td>8-bit character specification where o is an octal digit<sup id="cite_ref-msdn_5-8" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\"</td> <td>U+0022</td> <td>double quote (")<sup id="cite_ref-msdn_5-9" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\&</td> <td></td> <td>non-character used to delimit numeric escapes in Haskell<sup id="cite_ref-haskell_3-1" class="reference"><a href="#cite_note-haskell-3"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\'</td> <td>U+0027</td> <td>single quote (')<sup id="cite_ref-msdn_5-10" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\\</td> <td>U+005C</td> <td>backslash (\)<sup id="cite_ref-msdn_5-11" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr> <tr> <td>\?</td> <td>U+003F</td> <td>question mark (?)<sup id="cite_ref-msdn_5-12" class="reference"><a href="#cite_note-msdn-5"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup> </td></tr></tbody></table> <p>Note: Not all sequences in the list are supported by all parsers, and there may be other escape sequences which are not in the list. </p> <div class="mw-heading mw-heading3"><h3 id="Nested_escaping">Nested escaping</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=15" title="Edit section: Nested escaping"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>When code in one programming language is embedded inside another, embedded strings may require multiple levels of escaping. This is particularly common in regular expressions and SQL query within other languages, or other languages inside shell scripts. This double-escaping is often difficult to read and author. </p><p>Incorrect quoting of nested strings can present a security vulnerability. Use of untrusted data, as in data fields of an SQL query, should use <a href="/wiki/Prepared_statement" title="Prepared statement">prepared statements</a> to prevent a <a href="/wiki/Code_injection" title="Code injection">code injection</a> attack. In <a href="/wiki/PHP" title="PHP">PHP</a> 2 through 5.3, there was a feature called <a href="/wiki/Magic_quotes" title="Magic quotes">magic quotes</a> which automatically escaped strings (for convenience and security), but due to problems was removed from version 5.4 onward. </p> <div class="mw-heading mw-heading3"><h3 id="Raw_strings">Raw strings</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=16" title="Edit section: Raw strings"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>A few languages provide a method of specifying that a literal is to be processed without any language-specific interpretation. This avoids the need for escaping, and yields more legible strings. </p><p>Raw strings are particularly useful when a common character needs to be escaped, notably in regular expressions (nested as string literals), where backslash <code>\</code> is widely used, and in DOS/Windows <a href="/wiki/Path_(computing)" title="Path (computing)">paths</a>, where backslash is used as a path separator. The profusion of backslashes is known as <a href="/wiki/Leaning_toothpick_syndrome" title="Leaning toothpick syndrome">leaning toothpick syndrome</a>, and can be reduced by using raw strings. Compare escaped and raw pathnames in C#: </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="w"> </span><span class="s">"The Windows path is C:\\Foo\\Bar\\Baz\\"</span> <span class="w"> </span><span class="s">@"The Windows path is C:\Foo\Bar\Baz\"</span> </pre></div> <p>Extreme examples occur when these are combined – <a href="/wiki/Uniform_Naming_Convention" class="mw-redirect" title="Uniform Naming Convention">Uniform Naming Convention</a> paths begin with <code>\\</code>, and thus an escaped regular expression matching a UNC name begins with 8 backslashes, <code>"\\\\\\\\"</code>, due to needing to escape the string and the regular expression. Using raw strings reduces this to 4 (escaping in the regular expression), as in C# <code>@"\\\\"</code>. </p><p>In XML documents, <a href="/wiki/CDATA#CDATA_sections_in_XML" title="CDATA">CDATA</a> sections allows use of characters such as & and < without an XML parser attempting to interpret them as part of the structure of the document itself. This can be useful when including literal text and scripting code, to keep the document <a href="/wiki/Well-formed_XML_document" class="mw-redirect" title="Well-formed XML document">well formed</a>. </p> <div class="mw-highlight mw-highlight-lang-xml mw-content-ltr" dir="ltr"><pre><span></span><span class="cp"><![CDATA[ if (path!=null && depth<2) { add(path); } ]]></span> </pre></div> <div class="mw-heading mw-heading2"><h2 id="Multiline_string_literals">Multiline string literals</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=17" title="Edit section: Multiline string literals"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In many languages, string literals can contain literal newlines, spanning several lines. Alternatively, newlines can be escaped, most often as <code>\n</code>. For example: </p> <div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span><span class="nb">echo</span><span class="w"> </span><span class="s1">'foo</span> <span class="s1">bar'</span> </pre></div> <p>and </p> <div class="mw-highlight mw-highlight-lang-bash mw-content-ltr" dir="ltr"><pre><span></span><span class="nb">echo</span><span class="w"> </span>-e<span class="w"> </span><span class="s2">"foo\nbar"</span> </pre></div> <p>are both valid bash, producing: </p> <pre>foo bar </pre> <p>Languages that allow literal newlines include bash, Lua, Perl, PHP, R, and Tcl. In some other languages string literals cannot include newlines. </p><p>Two issues with multiline string literals are leading and trailing newlines, and indentation. If the initial or final delimiters are on separate lines, there are extra newlines, while if they are not, the delimiter makes the string harder to read, particularly for the first line, which is often indented differently from the rest. Further, the literal must be unindented, as leading whitespace is preserved – this breaks the flow of the code if the literal occurs within indented code. </p><p>The most common solution for these problems is <a href="/wiki/Here_document" title="Here document">here document</a>-style string literals. Formally speaking, a <a href="/wiki/Here_document" title="Here document">here document</a> is not a string literal, but instead a stream literal or file literal. These originate in shell scripts and allow a literal to be fed as input to an external command. The opening delimiter is <code><<END</code> where <code>END</code> can be any word, and the closing delimiter is <code>END</code> on a line by itself, serving as a content boundary – the <code><<</code> is due to redirecting <a href="/wiki/Stdin" class="mw-redirect" title="Stdin">stdin</a> from the literal. Due to the delimiter being arbitrary, these also avoid the problem of delimiter collision. These also allow initial tabs to be stripped via the variant syntax <code><<-END</code> though leading spaces are not stripped. The same syntax has since been adopted for multiline string literals in a number of languages, most notably Perl, and are also referred to as <i>here documents,</i> and retain the syntax, despite being strings and not involving redirection. As with other string literals, these can sometimes have different behavior specified, such as variable interpolation. </p><p>Python, whose usual string literals do not allow literal newlines, instead has a special form of string, designed for multiline literals, called <i>triple quoting</i>. These use a tripled delimiter, either <code>'''</code> or <code>"""</code>. These literals are especially used for inline documentation, known as <a href="/wiki/Docstring" title="Docstring">docstrings</a>. </p><p>Tcl allows literal newlines in strings and has no special syntax to assist with multiline strings, though delimiters can be placed on lines by themselves and leading and trailing newlines stripped via <code>string trim</code>, while <code>string map</code> can be used to strip indentation. </p> <div class="mw-heading mw-heading2"><h2 id="String_literal_concatenation">String literal concatenation</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=18" title="Edit section: String literal concatenation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1235681985">.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}</style><style data-mw-deduplicate="TemplateStyles:r1237033735">@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}</style><div class="side-box side-box-right plainlinks sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}</style> <div class="side-box-flex"> <div class="side-box-image"><span class="noviewer" typeof="mw:File"><span><img alt="" src="//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Wikifunctions-logo.svg/40px-Wikifunctions-logo.svg.png" decoding="async" width="40" height="40" class="mw-file-element" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Wikifunctions-logo.svg/60px-Wikifunctions-logo.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Wikifunctions-logo.svg/80px-Wikifunctions-logo.svg.png 2x" data-file-width="512" data-file-height="513" /></span></span></div> <div class="side-box-text plainlist"><a href="/wiki/Wikifunctions" title="Wikifunctions">Wikifunctions</a> has <b><a href="https://www.wikifunctions.org/wiki/Z10000" class="extiw" title="f:Z10000">a function related to this topic</a></b>.</div></div> </div> <p>A few languages provide <b>string literal concatenation</b>, where adjacent string literals are implicitly joined into a single literal at compile time. This is a feature of C,<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup> C++,<sup id="cite_ref-11" class="reference"><a href="#cite_note-11"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> D,<sup id="cite_ref-12" class="reference"><a href="#cite_note-12"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> Ruby,<sup id="cite_ref-13" class="reference"><a href="#cite_note-13"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> and Python,<sup id="cite_ref-14" class="reference"><a href="#cite_note-14"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> which copied it from C.<sup id="cite_ref-guidopythonideas_15-0" class="reference"><a href="#cite_note-guidopythonideas-15"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> Notably, this concatenation happens at compile time, during <a href="/wiki/Lexical_analysis" title="Lexical analysis">lexical analysis</a> (as a phase following initial tokenization), and is contrasted with both run time <a href="/wiki/String_concatenation" class="mw-redirect" title="String concatenation">string concatenation</a> (generally with the <code>+</code> operator)<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup> and concatenation during <a href="/wiki/Constant_folding" title="Constant folding">constant folding</a>, which occurs at compile time, but in a later phase (after phrase analysis or "parsing"). Most languages, such as C#, Java<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup> and Perl, do not support implicit string literal concatenation, and instead require explicit concatenation, such as with the <code>+</code> operator (this is also possible in D and Python, but illegal in C/C++ – see below); in this case concatenation may happen at compile time, via constant folding, or may be deferred to run time. </p> <div class="mw-heading mw-heading3"><h3 id="Motivation">Motivation</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=19" title="Edit section: Motivation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>In C, where the concept and term originate, string literal concatenation was introduced for two reasons:<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup> </p> <ul><li>To allow long strings to span multiple lines with proper indentation in contrast to line continuation, which destroys the indentation scheme; and</li> <li>To allow the construction of string literals by macros (via <a href="/wiki/Stringizing" class="mw-redirect" title="Stringizing">stringizing</a>).<sup id="cite_ref-19" class="reference"><a href="#cite_note-19"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup></li></ul> <p>In practical terms, this allows string concatenation in early phases of compilation ("translation", specifically as part of lexical analysis), without requiring phrase analysis or constant folding. For example, the following are valid C/C++: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"hello, "</span><span class="w"> </span><span class="s">"world"</span><span class="p">;</span> <span class="n">printf</span><span class="p">(</span><span class="s">"hello, "</span><span class="w"> </span><span class="s">"world"</span><span class="p">);</span> </pre></div> <p>However, the following are invalid: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">s</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"hello, "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s">"world"</span><span class="p">;</span> <span class="n">printf</span><span class="p">(</span><span class="s">"hello, "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s">"world"</span><span class="p">);</span> </pre></div> <p>This is because string literals have <a href="/wiki/Array_data_type" class="mw-redirect" title="Array data type">array type</a>, <code>char [<i>n</i>]</code> (C) or <code>const char [<i>n</i>]</code> (C++), which cannot be added; this is not a restriction in most other languages. </p><p>This is particularly important when used in combination with the <a href="/wiki/C_preprocessor" title="C preprocessor">C preprocessor</a>, to allow strings to be computed following preprocessing, particularly in macros.<sup id="cite_ref-guidopythonideas_15-1" class="reference"><a href="#cite_note-guidopythonideas-15"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> As a simple example: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">file_and_message</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">__FILE__</span><span class="w"> </span><span class="s">": message"</span><span class="p">;</span> </pre></div> <p>will (if the file is called a.c) expand to: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">file_and_message</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"a.c"</span><span class="w"> </span><span class="s">": message"</span><span class="p">;</span> </pre></div> <p>which is then concatenated, being equivalent to: </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">file_and_message</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"a.c: message"</span><span class="p">;</span> </pre></div> <p>A common use case is in constructing printf or scanf <a href="/w/index.php?title=Format_string&action=edit&redlink=1" class="new" title="Format string (page does not exist)">format strings</a>, where format specifiers are given by macros.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-21" class="reference"><a href="#cite_note-21"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup> </p><p>A more complex example uses <a rel="nofollow" class="external text" href="https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html">stringification</a> of integers (by the preprocessor) to define a macro that expands to a sequence of string literals, which are then concatenated to a single string literal with the file name and line number:<sup id="cite_ref-22" class="reference"><a href="#cite_note-22"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span></span><span class="cp">#define STRINGIFY(x) #x</span> <span class="cp">#define TOSTRING(x) STRINGIFY(x)</span> <span class="cp">#define AT __FILE__ ":" TOSTRING(__LINE__)</span> </pre></div> <p>Beyond syntactic requirements of C/C++, implicit concatenation is a form of <a href="/wiki/Syntactic_sugar" title="Syntactic sugar">syntactic sugar</a>, making it simpler to split string literals across several lines, avoiding the need for line continuation (via backslashes) and allowing one to add comments to parts of strings. For example, in Python, one can comment a <a href="/wiki/Regular_expression" title="Regular expression">regular expression</a> in this way:<sup id="cite_ref-23" class="reference"><a href="#cite_note-23"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s2">"[A-Za-z_]"</span> <span class="c1"># letter or underscore</span> <span class="s2">"[A-Za-z0-9_]*"</span> <span class="c1"># letter, digit or underscore</span> <span class="p">)</span> </pre></div> <div class="mw-heading mw-heading3"><h3 id="Problems">Problems</h3><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=20" title="Edit section: Problems"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Implicit string concatenation is not required by modern compilers, which implement constant folding, and causes hard-to-spot errors due to unintentional concatenation from omitting a comma, particularly in vertical lists of strings, as in: </p> <div class="mw-highlight mw-highlight-lang-python mw-content-ltr" dir="ltr"><pre><span></span><span class="n">l</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'foo'</span><span class="p">,</span> <span class="s1">'bar'</span> <span class="s1">'zork'</span><span class="p">]</span> </pre></div> <p>Accordingly, it is not used in most languages, and it has been proposed for deprecation from D<sup id="cite_ref-24" class="reference"><a href="#cite_note-24"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup> and Python.<sup id="cite_ref-guidopythonideas_15-2" class="reference"><a href="#cite_note-guidopythonideas-15"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> However, removing the feature breaks backwards compatibility, and replacing it with a concatenation operator introduces issues of precedence – string literal concatenation occurs during lexing, prior to operator evaluation, but concatenation via an explicit operator occurs at the same time as other operators, hence precedence is an issue, potentially requiring parentheses to ensure desired evaluation order. </p><p>A subtler issue is that in C and C++,<sup id="cite_ref-25" class="reference"><a href="#cite_note-25"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup> there are different types of string literals, and concatenation of these has implementation-defined behavior, which poses a potential security risk.<sup id="cite_ref-26" class="reference"><a href="#cite_note-26"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-heading mw-heading2"><h2 id="Different_kinds_of_strings">Different kinds of strings</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=21" title="Edit section: Different kinds of strings"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Some languages provide more than one kind of literal, which have different behavior. This is particularly used to indicate <a href="#Raw_strings">raw strings</a> (no escaping), or to disable or enable variable interpolation, but has other uses, such as distinguishing character sets. Most often this is done by changing the quoting character or adding a prefix or suffix. This is comparable to prefixes and suffixes to <a href="/wiki/Integer_literal" title="Integer literal">integer literals</a>, such as to indicate hexadecimal numbers or long integers. </p><p>One of the oldest examples is in shell scripts, where single quotes indicate a raw string or "literal string", while double quotes have escape sequences and variable interpolation. </p><p>For example, in <a href="/wiki/Python_(programming_language)" title="Python (programming language)">Python</a>, raw strings are preceded by an <code>r</code> or <code>R</code> – compare <code>'C:\\Windows'</code> with <code>r'C:\Windows'</code> (though, a Python raw string cannot end in an odd number of backslashes). Python 2 also distinguishes two types of strings: 8-bit ASCII ("bytes") strings (the default), explicitly indicated with a <code>b</code> or <code>B</code> prefix, and Unicode strings, indicated with a <code>u</code> or <code>U</code> prefix.<sup id="cite_ref-27" class="reference"><a href="#cite_note-27"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup> while in Python 3 strings are Unicode by default and bytes are a separate <code>bytes</code> type that when initialized with quotes must be prefixed with a <code>b</code>. </p><p><a href="/wiki/C_Sharp_(programming_language)" title="C Sharp (programming language)">C#</a>'s notation for raw strings is called @-quoting. </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="s">@"C:\Foo\Bar\Baz\"</span> </pre></div> <p>While this disables escaping, it allows double-up quotes, which allow one to represent quotes within the string: </p> <div class="mw-highlight mw-highlight-lang-csharp mw-content-ltr" dir="ltr"><pre><span></span><span class="s">@"I said, ""Hello there."""</span> </pre></div> <p><a href="/wiki/C%2B%2B11#New_string_literals" title="C++11">C++11 allows</a> raw strings, unicode strings (UTF-8, UTF-16, and UTF-32), and wide character strings, determined by prefixes. It also adds literals for the existing C++ <code>string</code>, which is generally preferred to the existing C-style strings. </p><p>In Tcl, brace-delimited strings are literal, while quote-delimited strings have escaping and interpolation. </p><p>Perl has a wide variety of strings, which are more formally considered operators, and are known as <b>quote and quote-like operators</b>. These include both a usual syntax (fixed delimiters) and a generic syntax, which allows a choice of delimiters; these include:<sup id="cite_ref-28" class="reference"><a href="#cite_note-28"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup> </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="s">''</span><span class="w"> </span><span class="s">""</span><span class="w"> </span><span class="sb">``</span><span class="w"> </span><span class="sr">//</span><span class="w"> </span><span class="sr">m//</span><span class="w"> </span><span class="sx">qr//</span><span class="w"> </span><span class="sr">s///</span><span class="w"> </span><span class="n">y</span><span class="sr">//</span><span class="o">/</span> <span class="sx">q{}</span><span class="w"> </span><span class="sx">qq{}</span><span class="w"> </span><span class="sx">qx{}</span><span class="w"> </span><span class="sx">qw{}</span><span class="w"> </span><span class="sr">m{}</span><span class="w"> </span><span class="sx">qr{}</span><span class="w"> </span><span class="sr">s{}{}</span><span class="w"> </span><span class="nb">tr</span><span class="p">{}{}</span><span class="w"> </span><span class="n">y</span><span class="p">{}{}</span> </pre></div> <p><a href="/wiki/REXX" class="mw-redirect" title="REXX">REXX</a> uses suffix characters to specify characters or strings using their hexadecimal or binary code. E.g., </p> <div class="mw-highlight mw-highlight-lang-rexx mw-content-ltr" dir="ltr"><pre><span></span><span class="s">'20'</span>x <span class="s">"0010 0000"</span>b <span class="s">"00100000"</span>b </pre></div> <p>all yield the <a href="/wiki/Space_character" class="mw-redirect" title="Space character">space character</a>, avoiding the function call <code>X2C(20)</code>. </p> <div class="mw-heading mw-heading2"><h2 id="String_interpolation">String interpolation</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=22" title="Edit section: String interpolation"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1236090951"><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="/wiki/String_interpolation" title="String interpolation">String interpolation</a></div> <p>In some languages, string literals may contain placeholders referring to variables or expressions in the current <a href="/wiki/Scope_(computer_science)" title="Scope (computer science)">context</a>, which are evaluated (usually at run time). This is referred to as <i>variable interpolation</i>, or more generally <a href="/wiki/String_interpolation" title="String interpolation">string interpolation</a>. Languages that support interpolation generally distinguish strings literals that are interpolated from ones that are not. For example, in <a href="/wiki/Bourne_shell" title="Bourne shell">sh-compatible Unix shells</a> (as well as Perl and Ruby), double-quoted (quotation-delimited, ") strings are interpolated, while single-quoted (apostrophe-delimited, ') strings are not. Non-interpolated string literals are sometimes referred to as "raw strings", but this is distinct from "raw string" in the sense of escaping. For example, in Python, a string prefixed with <code>r</code> or <code>R</code> has no escaping or interpolation, a normal string (no prefix) has escaping but no interpolation, and a string prefixed with <code>f</code> or <code>F</code> has escaping and interpolation. </p><p>For example, the following <a href="/wiki/Perl" title="Perl">Perl</a> code: </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nv">$name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"Nancy"</span><span class="p">;</span> <span class="nv">$greeting</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"Hello World"</span><span class="p">;</span> <span class="k">print</span><span class="w"> </span><span class="s">"$name said $greeting to the crowd of people."</span><span class="p">;</span> </pre></div> <p>produces the output: </p> <pre>Nancy said Hello World to the crowd of people. </pre> <p>In this case, the <a href="/wiki/Metacharacter" title="Metacharacter">metacharacter</a> character ($) (not to be confused with the <a href="/wiki/Sigil_(computer_programming)" title="Sigil (computer programming)">sigil</a> in the variable assignment statement) is interpreted to indicate variable interpolation, and requires some escaping if it needs to be outputted literally. </p><p>This should be contrasted with the <code><a href="/wiki/Printf" title="Printf">printf</a></code> function, which produces the same output using notation such as: </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="nb">printf</span><span class="w"> </span><span class="s">"%s said %s to the crowd of people."</span><span class="p">,</span><span class="w"> </span><span class="nv">$name</span><span class="p">,</span><span class="w"> </span><span class="nv">$greeting</span><span class="p">;</span> </pre></div> <p>but does not perform interpolation: the <code>%s</code> is a placeholder in a <a href="/wiki/Printf_format_string" class="mw-redirect" title="Printf format string">printf format string</a>, but the variables themselves are outside the string. </p><p>This is contrasted with "raw" strings: </p> <div class="mw-highlight mw-highlight-lang-perl mw-content-ltr" dir="ltr"><pre><span></span><span class="k">print</span><span class="w"> </span><span class="s">'$name said $greeting to the crowd of people.'</span><span class="p">;</span> </pre></div> <p>which produce output like: </p> <pre>$name said $greeting to the crowd of people. </pre> <p>Here the $ characters are not metacharacters, and are not interpreted to have any meaning other than plain text. </p> <div class="mw-heading mw-heading2"><h2 id="Embedding_source_code_in_string_literals">Embedding source code in string literals</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=23" title="Edit section: Embedding source code in string literals"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <p>Languages that lack flexibility in specifying string literals make it particularly cumbersome to write programming code that generates other programming code. This is particularly true when the generation language is the same or similar to the output language. </p><p>For example: </p> <ul><li>writing code to produce <a href="/wiki/Quine_(computing)" title="Quine (computing)">quines</a></li> <li>generating an output language from within a <a href="/wiki/Web_template" class="mw-redirect" title="Web template">web template</a>;</li> <li>using <a href="/wiki/XSLT" title="XSLT">XSLT</a> to generate XSLT, or <a href="/wiki/SQL" title="SQL">SQL</a> to generate more SQL</li> <li>generating a <a href="/wiki/PostScript" title="PostScript">PostScript</a> representation of a document for printing purposes, from within a document-processing application written in <a href="/wiki/C_(programming_language)" title="C (programming language)">C</a> or some other language.</li></ul> <p>Nevertheless, some languages are particularly well-adapted to produce this sort of self-similar output, especially those that support multiple options for avoiding delimiter collision. </p><p>Using string literals as code that generates other code may have adverse security implications, especially if the output is based at least partially on untrusted user input. This is particularly acute in the case of Web-based applications, where malicious users can take advantage of such weaknesses to subvert the operation of the application, for example by mounting an <a href="/wiki/SQL_injection" title="SQL injection">SQL injection</a> attack. </p> <div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=24" title="Edit section: See also"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a href="/wiki/Character_literal" title="Character literal">Character literal</a></li> <li><a href="/wiki/XML_Literals" title="XML Literals">XML Literals</a></li> <li><a href="/wiki/Sigil_(computer_programming)" title="Sigil (computer programming)">Sigil (computer programming)</a></li></ul> <div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=25" title="Edit section: Notes"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <style data-mw-deduplicate="TemplateStyles:r1239543626">.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}</style><div class="reflist reflist-lower-alpha"> <div class="mw-references-wrap"><ol class="references"> <li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text">The regex given here is not itself quoted or escaped, to reduce confusion.</span> </li> <li id="cite_note-encoding-8"><span class="mw-cite-backlink">^ <a href="#cite_ref-encoding_8-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-encoding_8-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text">Since this escape sequence represents a specific <a href="/wiki/Code_unit" class="mw-redirect" title="Code unit">code unit</a> instead of a specific character, what code point (if any) it represents depends on the encoding of the string literal it is found in.</span> </li> </ol></div></div> <div class="mw-heading mw-heading2"><h2 id="References">References</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=26" title="Edit section: References"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1239543626"><div class="reflist reflist-columns references-column-width" style="column-width: 30em;"> <ol class="references"> <li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.lysator.liu.se/c/ANSI-C-grammar-l.html">"ANSI C grammar (Lex)"</a>. <i>liu.se</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 June</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=liu.se&rft.atitle=ANSI+C+grammar+%28Lex%29&rft_id=http%3A%2F%2Fwww.lysator.liu.se%2Fc%2FANSI-C-grammar-l.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-haskell-3"><span class="mw-cite-backlink">^ <a href="#cite_ref-haskell_3-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-haskell_3-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://book.realworldhaskell.org/read/characters-strings-and-escaping-rules.html">"Appendix B. Characters, strings, and escaping rules"</a>. <i>realworldhaskell.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 June</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=realworldhaskell.org&rft.atitle=Appendix+B.+Characters%2C+strings%2C+and+escaping+rules&rft_id=http%3A%2F%2Fbook.realworldhaskell.org%2Fread%2Fcharacters-strings-and-escaping-rules.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-javascript-4"><span class="mw-cite-backlink">^ <a href="#cite_ref-javascript_4-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-javascript_4-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">"String"</a>. <i>mozilla.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 June</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=mozilla.org&rft.atitle=String&rft_id=https%3A%2F%2Fdeveloper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FJavaScript%2FReference%2FGlobal_Objects%2FString&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-msdn-5"><span class="mw-cite-backlink">^ <a href="#cite_ref-msdn_5-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-msdn_5-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-msdn_5-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-msdn_5-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-msdn_5-4"><sup><i><b>e</b></i></sup></a> <a href="#cite_ref-msdn_5-5"><sup><i><b>f</b></i></sup></a> <a href="#cite_ref-msdn_5-6"><sup><i><b>g</b></i></sup></a> <a href="#cite_ref-msdn_5-7"><sup><i><b>h</b></i></sup></a> <a href="#cite_ref-msdn_5-8"><sup><i><b>i</b></i></sup></a> <a href="#cite_ref-msdn_5-9"><sup><i><b>j</b></i></sup></a> <a href="#cite_ref-msdn_5-10"><sup><i><b>k</b></i></sup></a> <a href="#cite_ref-msdn_5-11"><sup><i><b>l</b></i></sup></a> <a href="#cite_ref-msdn_5-12"><sup><i><b>m</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://msdn.microsoft.com/en-us/library/h21280bw(v=vs.80).aspx">"Escape Sequences (C)"</a>. <i>microsoft.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 June</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=microsoft.com&rft.atitle=Escape+Sequences+%28C%29&rft_id=http%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Flibrary%2Fh21280bw%28v%3Dvs.80%29.aspx&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-Rationale_2003_C-6"><span class="mw-cite-backlink">^ <a href="#cite_ref-Rationale_2003_C_6-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Rationale_2003_C_6-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf">"Rationale for International Standard - Programming Languages - C"</a> <span class="cs1-format">(PDF)</span>. 5.10. April 2003. pp. 52, 153–154, 159. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160606072228/http://www.open-std.org/jtc1/sc22/wg14/www/C99RationaleV5.10.pdf">Archived</a> <span class="cs1-format">(PDF)</span> from the original on 2016-06-06<span class="reference-accessdate">. Retrieved <span class="nowrap">2010-10-17</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Rationale+for+International+Standard+-+Programming+Languages+-+C&rft.series=5.10&rft.pages=52%2C+153-154%2C+159&rft.date=2003-04&rft_id=http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg14%2Fwww%2FC99RationaleV5.10.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation cs2"><a rel="nofollow" class="external text" href="https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Character-Escapes.html#Character-Escapes">"6.35 The Character <ESC> in Constants"</a>, <i>GCC 4.8.2 Manual</i><span class="reference-accessdate">, retrieved <span class="nowrap">2014-03-08</span></span></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=bookitem&rft.atitle=6.35+The+Character+%3CESC%3E+in+Constants&rft.btitle=GCC+4.8.2+Manual&rft_id=https%3A%2F%2Fgcc.gnu.org%2Fonlinedocs%2Fgcc-4.8.2%2Fgcc%2FCharacter-Escapes.html%23Character-Escapes&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><a href="/wiki/C11_(C_standard_revision)" title="C11 (C standard revision)">C11</a> draft standard, <a rel="nofollow" class="external text" href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf">WG14 N1570 Committee Draft — April 12, 2011</a>, 5.1.1.2 Translation phases, p. 11: "6. Adjacent string literal tokens are concatenated."</span> </li> <li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><a href="/wiki/C_syntax#String_literal_concatenation" title="C syntax">C syntax: String literal concatenation</a></span> </li> <li id="cite_note-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-11">^</a></b></span> <span class="reference-text"><a href="/wiki/C%2B%2B11" title="C++11">C++11</a> draft standard, <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf">"Working Draft, Standard for Programming Language C++"</a> <span class="cs1-format">(PDF)</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Working+Draft%2C+Standard+for+Programming+Language+C%2B%2B&rft_id=http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2012%2Fn3337.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span>, 2.2 Phases of translation [lex.phases], p. 17: "6. Adjacent string literal tokens are concatenated." and 2.14.5 String literals [lex.string], note 13, p. 28–29: "In translation phase 6 (2.2), adjacent string literals are concatenated."</span> </li> <li id="cite_note-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-12">^</a></b></span> <span class="reference-text"><i><a rel="nofollow" class="external text" href="http://dlang.org/">D Programming Language</a>,</i> <a rel="nofollow" class="external text" href="http://dlang.org/lex">Lexical Analysis</a>, "String Literals": "Adjacent strings are concatenated with the ~ operator, or by simple juxtaposition:"</span> </li> <li id="cite_note-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-13">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation cs2"><a rel="nofollow" class="external text" href="https://github.com/ruby/ruby"><i>ruby: The Ruby Programming Language</i></a>, Ruby Programming Language, 2017-10-19<span class="reference-accessdate">, retrieved <span class="nowrap">2017-10-19</span></span></cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=ruby%3A+The+Ruby+Programming+Language&rft.pub=Ruby+Programming+Language&rft.date=2017-10-19&rft_id=https%3A%2F%2Fgithub.com%2Fruby%2Fruby&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-14">^</a></b></span> <span class="reference-text">The Python Language Reference, 2. Lexical analysis, <a rel="nofollow" class="external text" href="https://docs.python.org/2/reference/lexical_analysis.html#string-literal-concatenation">2.4.2. String literal concatenation</a>: "Multiple adjacent string literals (delimited by whitespace), possibly using different quoting conventions, are allowed, and their meaning is the same as their concatenation."</span> </li> <li id="cite_note-guidopythonideas-15"><span class="mw-cite-backlink">^ <a href="#cite_ref-guidopythonideas_15-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-guidopythonideas_15-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-guidopythonideas_15-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text">Python-ideas, "<a rel="nofollow" class="external text" href="https://mail.python.org/pipermail/python-ideas/2013-May/020527.html">Implicit string literal concatenation considered harmful?</a>", Guido van Rossum, May 10, 2013</span> </li> <li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text">The Python Language Reference, 2. Lexical analysis, <a rel="nofollow" class="external text" href="https://docs.python.org/2/reference/lexical_analysis.html#string-literal-concatenation">2.4.2. String literal concatenation</a>: "Note that this feature is defined at the syntactical level, but implemented at compile time. The ‘+’ operator must be used to concatenate string expressions at run time."</span> </li> <li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://docs.oracle.com/javase/tutorial/java/data/strings.html">"Strings (The Java™ Tutorials > Learning the Java Language > Numbers and Strings)"</a>. <i>Docs.oracle.com</i>. 2012-02-28<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-06-22</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Docs.oracle.com&rft.atitle=Strings+%28The+Java%E2%84%A2+Tutorials+%3E+Learning+the+Java+Language+%3E+Numbers+and+Strings%29&rft.date=2012-02-28&rft_id=http%3A%2F%2Fdocs.oracle.com%2Fjavase%2Ftutorial%2Fjava%2Fdata%2Fstrings.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation book cs1"><a rel="nofollow" class="external text" href="http://www.lysator.liu.se/c/rat/title.html"><i>Rationale for the ANSI C Programming Language</i></a>. Silicon Press. 1990. p. <a rel="nofollow" class="external text" href="https://books.google.com/books?id=yxLISD0TAbEC&q=%22String%20literal%20concatenation%22&pg=PA31">31</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-929306-07-4" title="Special:BookSources/0-929306-07-4"><bdi>0-929306-07-4</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Rationale+for+the+ANSI+C+Programming+Language&rft.pages=31&rft.pub=Silicon+Press&rft.date=1990&rft.isbn=0-929306-07-4&rft_id=http%3A%2F%2Fwww.lysator.liu.se%2Fc%2Frat%2Ftitle.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span>, <a rel="nofollow" class="external text" href="http://www.lysator.liu.se/c/rat/c1.html#3-1-4">3.1.4 String literals</a>: "A long string can be continued across multiple lines by using the backslash-newline line continuation, but this practice requires that the continuation of the string start in the first position of the next line. To permit more flexible layout, and to solve some preprocessing problems (see §3.8.3), the Committee introduced string literal concatenation. Two string literals in a row are pasted together (with no null character in the middle) to make one combined string literal. This addition to the C language allows a programmer to extend a string literal beyond the end of a physical line without having to use the backslash-newline mechanism and thereby destroying the indentation scheme of the program. An explicit concatenation operator was not introduced because the concatenation is a lexical construct rather than a run-time operation."</span> </li> <li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation book cs1"><a rel="nofollow" class="external text" href="http://www.lysator.liu.se/c/rat/title.html"><i>Rationale for the ANSI C Programming Language</i></a>. Silicon Press. 1990. p. <a rel="nofollow" class="external text" href="https://books.google.com/books?id=yxLISD0TAbEC&q=%22String%20literal%20concatenation%22&pg=PA65">6566</a>. <a href="/wiki/ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <a href="/wiki/Special:BookSources/0-929306-07-4" title="Special:BookSources/0-929306-07-4"><bdi>0-929306-07-4</bdi></a>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=book&rft.btitle=Rationale+for+the+ANSI+C+Programming+Language&rft.pages=6566&rft.pub=Silicon+Press&rft.date=1990&rft.isbn=0-929306-07-4&rft_id=http%3A%2F%2Fwww.lysator.liu.se%2Fc%2Frat%2Ftitle.html&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span>, <a rel="nofollow" class="external text" href="http://www.lysator.liu.se/c/rat/c8.html#3-8-3-2">3.8.3.2 The # operator</a>: "The # operator has been introduced for stringizing. It may only be used in a #define expansion. It causes the formal parameter name following to be replaced by a string literal formed by stringizing the actual argument token sequence. In conjunction with string literal concatenation (see §3.1.4), use of this operator permits the construction of strings as effectively as by identifier replacement within a string. An example in the Standard illustrates this feature."</span> </li> <li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><i>C/C++ Users Journal,</i> Volume 19, <a rel="nofollow" class="external text" href="https://books.google.com/books?id=gGpVAAAAMAAJ&q=%22string+literal+concatenation%22">p. 50</a></span> </li> <li id="cite_note-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-21">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://stackoverflow.com/questions/2504536/why-allow-concatenation-of-string-literals">"python - Why allow concatenation of string literals?"</a>. Stack Overflow<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-06-22</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=python+-+Why+allow+concatenation+of+string+literals%3F&rft.pub=Stack+Overflow&rft_id=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F2504536%2Fwhy-allow-concatenation-of-string-literals&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-22"><span class="mw-cite-backlink"><b><a href="#cite_ref-22">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.decompile.com/cpp/faq/file_and_line_error_string.htm">"LINE__ to string (stringify) using preprocessor directives"</a>. <i>Decompile.com</i>. 2006-10-12<span class="reference-accessdate">. Retrieved <span class="nowrap">2016-06-22</span></span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=Decompile.com&rft.atitle=LINE__+to+string+%28stringify%29+using+preprocessor+directives&rft.date=2006-10-12&rft_id=http%3A%2F%2Fwww.decompile.com%2Fcpp%2Ffaq%2Ffile_and_line_error_string.htm&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-23"><span class="mw-cite-backlink"><b><a href="#cite_ref-23">^</a></b></span> <span class="reference-text">The Python Language Reference, 2. Lexical analysis, <a rel="nofollow" class="external text" href="https://docs.python.org/2/reference/lexical_analysis.html#string-literal-concatenation">2.4.2. String literal concatenation</a>: "This feature can be used to reduce the number of backslashes needed, to split long strings conveniently across long lines, or even to add comments to parts of strings, for example:</span> </li> <li id="cite_note-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-24">^</a></b></span> <span class="reference-text">DLang's Issue Tracking System – <a rel="nofollow" class="external text" href="https://issues.dlang.org/show_bug.cgi?id=3827">Issue 3827</a> - Warn against and then deprecate implicit concatenation of adjacent string literals</span> </li> <li id="cite_note-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-25">^</a></b></span> <span class="reference-text"><a href="/wiki/C%2B%2B11" title="C++11">C++11</a> draft standard, <link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf">"Working Draft, Standard for Programming Language C++"</a> <span class="cs1-format">(PDF)</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=Working+Draft%2C+Standard+for+Programming+Language+C%2B%2B&rft_id=http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2012%2Fn3337.pdf&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span>, 2.14.5 String literals [lex.string], note 13, p. 28–29: "Any other concatenations are conditionally supported with implementation-defined behavior."</span> </li> <li id="cite_note-26"><span class="mw-cite-backlink"><b><a href="#cite_ref-26">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20140714135237/https://www.securecoding.cert.org/confluence/display/seccode/STR10-C.+Do+not+concatenate+different+type+of+string+literals">"STR10-C. Do not concatenate different type of string literals - Secure Coding - CERT Secure Coding Standards"</a>. Archived from <a rel="nofollow" class="external text" href="https://www.securecoding.cert.org/confluence/display/seccode/STR10-C.+Do+not+concatenate+different+type+of+string+literals">the original</a> on July 14, 2014<span class="reference-accessdate">. Retrieved <span class="nowrap">July 3,</span> 2014</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rft.genre=unknown&rft.btitle=STR10-C.+Do+not+concatenate+different+type+of+string+literals+-+Secure+Coding+-+CERT+Secure+Coding+Standards&rft_id=https%3A%2F%2Fwww.securecoding.cert.org%2Fconfluence%2Fdisplay%2Fseccode%2FSTR10-C.%2BDo%2Bnot%2Bconcatenate%2Bdifferent%2Btype%2Bof%2Bstring%2Bliterals&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-27"><span class="mw-cite-backlink"><b><a href="#cite_ref-27">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.python.org/2/reference/lexical_analysis.html#string-literals">"2. Lexical analysis — Python 2.7.12rc1 documentation"</a>. <i>python.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 June</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=python.org&rft.atitle=2.+Lexical+analysis+%E2%80%94+Python+2.7.12rc1+documentation&rft_id=https%3A%2F%2Fdocs.python.org%2F2%2Freference%2Flexical_analysis.html%23string-literals&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> <li id="cite_note-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-28">^</a></b></span> <span class="reference-text"><link rel="mw-deduplicated-inline-style" href="mw-data:TemplateStyles:r1238218222"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://perldoc.perl.org/perlop.html#Quote-and-Quote-like-Operators">"perlop - perldoc.perl.org"</a>. <i>perl.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 June</span> 2016</span>.</cite><span title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rft.genre=unknown&rft.jtitle=perl.org&rft.atitle=perlop+-+perldoc.perl.org&rft_id=http%3A%2F%2Fperldoc.perl.org%2Fperlop.html%23Quote-and-Quote-like-Operators&rfr_id=info%3Asid%2Fen.wikipedia.org%3AString+literal" class="Z3988"></span></span> </li> </ol></div> <div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/w/index.php?title=String_literal&action=edit&section=27" title="Edit section: External links"><span>edit</span></a><span class="mw-editsection-bracket">]</span></span></div> <ul><li><a rel="nofollow" class="external text" href="http://www.gavilan.edu/csis/languages/literals.html">Literals In Programming</a></li></ul> <!-- NewPP limit report Parsed by mw‐web.eqiad.main‐5dc468848‐r4vhn Cached time: 20241122141706 Cache expiry: 2592000 Reduced expiry: false Complications: [vary‐revision‐sha1, show‐toc] CPU time usage: 0.525 seconds Real time usage: 3.190 seconds Preprocessor visited node count: 2202/1000000 Post‐expand include size: 34125/2097152 bytes Template argument size: 2563/2097152 bytes Highest expansion depth: 12/100 Expensive parser function count: 39/500 Unstrip recursion depth: 1/20 Unstrip post‐expand size: 88620/5000000 bytes Lua time usage: 0.244/10.000 seconds Lua memory usage: 5932861/52428800 bytes Number of Wikibase entities loaded: 0/400 --> <!-- Transclusion expansion time report (%,ms,calls,template) 100.00% 3101.332 1 -total 6.60% 204.659 2 Template:Reflist 4.69% 145.462 13 Template:Cite_web 3.59% 111.247 1 Template:Short_description 1.90% 59.074 2 Template:Pagetype 1.86% 57.832 2 Template:Citation_needed 1.59% 49.240 2 Template:Fix 1.22% 37.739 7 Template:Main_other 1.12% 34.848 3 Template:Main 1.06% 33.018 1 Template:Wikifunctions --> <!-- Saved in parser cache with key enwiki:pcache:idhash:199706-0!canonical and timestamp 20241122141706 and revision id 1254523808. Rendering was triggered because: page-view --> </div><!--esi <esi:include src="/esitest-fa8a495983347898/content" /> --><noscript><img src="https://login.wikimedia.org/wiki/Special:CentralAutoLogin/start?type=1x1" alt="" width="1" height="1" style="border: none; position: absolute;"></noscript> <div class="printfooter" data-nosnippet="">Retrieved from "<a dir="ltr" href="https://en.wikipedia.org/w/index.php?title=String_literal&oldid=1254523808">https://en.wikipedia.org/w/index.php?title=String_literal&oldid=1254523808</a>"</div></div> <div id="catlinks" class="catlinks" data-mw="interface"><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="/wiki/Help:Category" title="Help:Category">Categories</a>: <ul><li><a href="/wiki/Category:Source_code" title="Category:Source code">Source code</a></li><li><a href="/wiki/Category:String_(computer_science)" title="Category:String (computer science)">String (computer science)</a></li></ul></div><div id="mw-hidden-catlinks" class="mw-hidden-catlinks mw-hidden-cats-hidden">Hidden categories: <ul><li><a href="/wiki/Category:Articles_with_short_description" title="Category:Articles with short description">Articles with short description</a></li><li><a href="/wiki/Category:Short_description_matches_Wikidata" title="Category:Short description matches Wikidata">Short description matches Wikidata</a></li><li><a href="/wiki/Category:All_articles_with_unsourced_statements" title="Category:All articles with unsourced statements">All articles with unsourced statements</a></li><li><a href="/wiki/Category:Articles_with_unsourced_statements_from_March_2011" title="Category:Articles with unsourced statements from March 2011">Articles with unsourced statements from March 2011</a></li><li><a href="/wiki/Category:Articles_with_unsourced_statements_from_February_2012" title="Category:Articles with unsourced statements from February 2012">Articles with unsourced statements from February 2012</a></li><li><a href="/wiki/Category:Articles_with_example_Python_(programming_language)_code" title="Category:Articles with example Python (programming language) code">Articles with example Python (programming language) code</a></li></ul></div></div> </div> </main> </div> <div class="mw-footer-container"> <footer id="footer" class="mw-footer" > <ul id="footer-info"> <li id="footer-info-lastmod"> This page was last edited on 31 October 2024, at 12:14<span class="anonymous-show"> (UTC)</span>.</li> <li id="footer-info-copyright">Text is available under the <a href="/wiki/Wikipedia:Text_of_the_Creative_Commons_Attribution-ShareAlike_4.0_International_License" title="Wikipedia:Text of the Creative Commons Attribution-ShareAlike 4.0 International License">Creative Commons Attribution-ShareAlike 4.0 License</a>; additional terms may apply. By using this site, you agree to the <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Terms_of_Use" class="extiw" title="foundation:Special:MyLanguage/Policy:Terms of Use">Terms of Use</a> and <a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy" class="extiw" title="foundation:Special:MyLanguage/Policy:Privacy policy">Privacy Policy</a>. Wikipedia® is a registered trademark of the <a rel="nofollow" class="external text" href="https://wikimediafoundation.org/">Wikimedia Foundation, Inc.</a>, a non-profit organization.</li> </ul> <ul id="footer-places"> <li id="footer-places-privacy"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Privacy_policy">Privacy policy</a></li> <li id="footer-places-about"><a href="/wiki/Wikipedia:About">About Wikipedia</a></li> <li id="footer-places-disclaimers"><a href="/wiki/Wikipedia:General_disclaimer">Disclaimers</a></li> <li id="footer-places-contact"><a href="//en.wikipedia.org/wiki/Wikipedia:Contact_us">Contact Wikipedia</a></li> <li id="footer-places-wm-codeofconduct"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Universal_Code_of_Conduct">Code of Conduct</a></li> <li id="footer-places-developers"><a href="https://developer.wikimedia.org">Developers</a></li> <li id="footer-places-statslink"><a href="https://stats.wikimedia.org/#/en.wikipedia.org">Statistics</a></li> <li id="footer-places-cookiestatement"><a href="https://foundation.wikimedia.org/wiki/Special:MyLanguage/Policy:Cookie_statement">Cookie statement</a></li> <li id="footer-places-mobileview"><a href="//en.m.wikipedia.org/w/index.php?title=String_literal&mobileaction=toggle_view_mobile" class="noprint stopMobileRedirectToggle">Mobile view</a></li> </ul> <ul id="footer-icons" class="noprint"> <li id="footer-copyrightico"><a href="https://wikimediafoundation.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/static/images/footer/wikimedia-button.svg" width="84" height="29" alt="Wikimedia Foundation" loading="lazy"></a></li> <li id="footer-poweredbyico"><a href="https://www.mediawiki.org/" class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled"><img src="/w/resources/assets/poweredby_mediawiki.svg" alt="Powered by MediaWiki" width="88" height="31" loading="lazy"></a></li> </ul> </footer> </div> </div> </div> <div class="vector-settings" id="p-dock-bottom"> <ul></ul> </div><script>(RLQ=window.RLQ||[]).push(function(){mw.config.set({"wgHostname":"mw-web.codfw.main-6bcf67d78c-f6fd4","wgBackendResponseTime":175,"wgPageParseReport":{"limitreport":{"cputime":"0.525","walltime":"3.190","ppvisitednodes":{"value":2202,"limit":1000000},"postexpandincludesize":{"value":34125,"limit":2097152},"templateargumentsize":{"value":2563,"limit":2097152},"expansiondepth":{"value":12,"limit":100},"expensivefunctioncount":{"value":39,"limit":500},"unstrip-depth":{"value":1,"limit":20},"unstrip-size":{"value":88620,"limit":5000000},"entityaccesscount":{"value":0,"limit":400},"timingprofile":["100.00% 3101.332 1 -total"," 6.60% 204.659 2 Template:Reflist"," 4.69% 145.462 13 Template:Cite_web"," 3.59% 111.247 1 Template:Short_description"," 1.90% 59.074 2 Template:Pagetype"," 1.86% 57.832 2 Template:Citation_needed"," 1.59% 49.240 2 Template:Fix"," 1.22% 37.739 7 Template:Main_other"," 1.12% 34.848 3 Template:Main"," 1.06% 33.018 1 Template:Wikifunctions"]},"scribunto":{"limitreport-timeusage":{"value":"0.244","limit":"10.000"},"limitreport-memusage":{"value":5932861,"limit":52428800}},"cachereport":{"origin":"mw-web.eqiad.main-5dc468848-r4vhn","timestamp":"20241122141706","ttl":2592000,"transientcontent":false}}});});</script> <script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"Article","name":"String literal","url":"https:\/\/en.wikipedia.org\/wiki\/String_literal","sameAs":"http:\/\/www.wikidata.org\/entity\/Q4736519","mainEntity":"http:\/\/www.wikidata.org\/entity\/Q4736519","author":{"@type":"Organization","name":"Contributors to Wikimedia projects"},"publisher":{"@type":"Organization","name":"Wikimedia Foundation, Inc.","logo":{"@type":"ImageObject","url":"https:\/\/www.wikimedia.org\/static\/images\/wmf-hor-googpub.png"}},"datePublished":"2003-03-22T01:59:10Z","dateModified":"2024-10-31T12:14:40Z","headline":"notation for representing a string in source code"}</script> </body> </html>