[#absl-CUnescape-06]
= xref:absl.adoc[absl]::CUnescape
:relfileprefix: ../
:mrdocs:

Unescapes a `source` string and copies it into `dest`, rewriting C&hyphen;style escape sequences (https&colon;&sol;&sol;en&period;cppreference&period;com&sol;w&sol;cpp&sol;language&sol;escape) into their proper code point equivalents, returning `true` if successful&period;

== Synopsis

Declared in `&lt;absl&sol;strings&sol;escaping&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
bool
CUnescape(
    std::string&lowbar;view source,
    std::string* dest,
    std::string* error);
----

== Description

The following unescape sequences can be handled&colon;

&ast; ASCII escape sequences (&apos; &apos;,&apos;r&apos;,&apos;&apos;, etc&period;) to their ASCII equivalents &ast; Octal escape sequences (&apos;nnn&apos;) to byte nnn&period; The unescaped value must resolve to a single byte or an error will occur&period; E&period;g&period; values greater than 0xff will produce an error&period; &ast; Hexadecimal escape sequences (&apos;xnn&apos;) to byte nn&period; While an arbitrary number of following digits are allowed, the unescaped value must resolve to a single byte or an error will occur&period; E&period;g&period; &apos;x0045&apos; is equivalent to &apos;x45&apos;, but &apos;x1234&apos; will produce an error&period; &ast; Unicode escape sequences (&apos;unnnn&apos; for exactly four hex digits or &apos;Unnnnnnnn&apos; for exactly eight hex digits, which will be encoded in UTF&hyphen;8&period; (E&period;g&period;, `u2019` unescapes to the three bytes 0xE2, 0x80, and 0x99)&period;

If any errors are encountered, this function returns `false`, leaving the `dest` output parameter in an unspecified state, and stores the first encountered error in `error`&period; To disable error reporting, set `error` to `nullptr` or use the overload with no error reporting below&period;

Example&colon;

std&colon;&colon;string s &equals; &quot;foo&bsol;rbar&bsol;nbaz&bsol;t&quot;&semi; std&colon;&colon;string unescaped&lowbar;s&semi; if (!absl&colon;&colon;CUnescape(s, &amp;unescaped&lowbar;s)) &lcub; &period;&period;&period; &rcub; EXPECT&lowbar;EQ(unescaped&lowbar;s, &quot;foorbarnbazt&quot;)&semi;

== Return Value

`true` on success, `false` if an error was encountered&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *source*
| The escaped string to unescape&period;
| *dest*
| The output string that receives the unescaped result&period;
| *error*
| Receives the first error encountered, or `nullptr` to disable error reporting&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
