MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / atoesc

Function atoesc

External/tiny-json/tiny-json.c:562–582  ·  view source on GitHub ↗

Copy a null-terminated string inserting escape characters if needed. * @param dest Destination memory block. * @param src Source string. * @return Pointer to the null character of the destination string. */

Source from the content-addressed store, hash-verified

560 * @param src Source string.
561 * @return Pointer to the null character of the destination string. */
562static char* atoesc( char* dest, char const* src ) {
563 for( ; *src != '\0'; ++dest, ++src ) {
564 if ( *src >= ' ' && *src != '\"' && *src != '\\' && *src != '/' )
565 *dest = *src;
566 else {
567 *dest++ = '\\';
568 int const esc = escape( *src );
569 if ( esc )
570 *dest = esc;
571 else {
572 *dest++ = 'u';
573 *dest++ = '0';
574 *dest++ = '0';
575 *dest++ = nibbletoch( *src / 16 );
576 *dest++ = nibbletoch( *src );
577 }
578 }
579 }
580 *dest = '\0';
581 return dest;
582}
583
584/* Add a text property in a JSON string. */
585char* json_str( char* dest, char const* name, char const* value ) {

Callers 1

json_strFunction · 0.85

Calls 2

escapeFunction · 0.85
nibbletochFunction · 0.85

Tested by

no test coverage detected