src/Drupal/Component/Utility/Tags.php
public static function encode($tag) {
    if (strpos($tag, ',') !== FALSE || strpos($tag, '"') !== FALSE) {
      return '"' . str_replace('"', '""', $tag) . '"';
    }
    return $tag;
  }
public static function encode($tag) {
    if (strpos($tag, ',') !== FALSE || strpos($tag, '"') !== FALSE) {
      return '"' . str_replace('"', '""', $tag) . '"';
    }
    return $tag;
  }
public static function encode ( $ tag ) { if ( strpos ( $ tag , ',' ) !== FALSE || strpos ( $ tag , '"' ) !== FALSE ) { return '"' . str_replace ( '"' , '""' , $ tag ) . '"' ; } return $ tag ; }
Encodes a tag string, taking care of special cases like commas and quotes.

@param string $tag
A tag string.

@return string
The encoded string.
Encodes a tag string taking care of special cases like commas and quotes .