Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. GPBJsonWire.php

function GPBJsonWire::escapedJson

File

vendor/google/protobuf/src/Google/Protobuf/Internal/GPBJsonWire.php, line 252

Class

GPBJsonWire

Namespace

Google\Protobuf\Internal

Code

public static function escapedJson($value) {
    $escaped_value = "";
    $unescaped_run = "";
    for ($i = 0; $i < strlen($value); $i++) {
        $c = $value[$i];
        // Handle escaping.
        if (static::isJsonEscaped($c)) {
            // Use a "nice" escape, like \n, if one exists for this
            // character.
            $escape = static::jsonNiceEscape($c);
            if (is_null($escape)) {
                $escape = "\\u00" . bin2hex($c);
            }
            if ($unescaped_run !== "") {
                $escaped_value .= $unescaped_run;
                $unescaped_run = "";
            }
            $escaped_value .= $escape;
        }
        else {
            if ($unescaped_run === "") {
                $unescaped_run .= $c;
            }
        }
    }
    $escaped_value .= $unescaped_run;
    return $escaped_value;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal