```{index} single: XString ``` # XString ```{pperl-module-badges} XString ``` The string quoting helpers of `B`, without loading `B`. `XString::cstring` and `XString::perlstring` return a string quoted and escaped so that it reads back as the same bytes: as a C string literal, or as a Perl double-quoted string. They are `B::cstring` and `B::perlstring`, packaged so that a module can quote strings without pulling in the compiler backend. ## Synopsis ```perl use XString; print XString::cstring(qq[a"b\n]), "\n"; # "a\"b\n" print XString::perlstring('cost: $5 @ 2'), "\n"; # "cost: \$5 \@ 2" print XString::cstring(undef), "\n"; # 0 ``` Nothing is exported; call them by their full names. This is a native implementation of XString 0.005's `XString.xs`; its `XString.pm` is used unchanged. ## Differences from upstream None. ## Functions ### Quoting #### [`cstring`](XString/cstring) Quote a string as a C string literal. #### [`perlstring`](XString/perlstring) Quote a string as a Perl double-quoted string. ```{toctree} :hidden: :maxdepth: 1 XString/cstring XString/perlstring ```