Back to InputFilter class

Method emailToPunycode

public string
emailToPunycode
(mixed $text)
Function to punyencode utf8 mail when saving content
Parameters
  • string $text The strings to encode
Returns
  • string The punyencoded mail
Since
  • 3.5
Class: InputFilter
Project: Joomla

Method emailToPunycode - Source code

/**
 * Function to punyencode utf8 mail when saving content
 *
 * @param   string  $text  The strings to encode
 *
 * @return  string  The punyencoded mail
 *
 * @since   3.5
 */
public function emailToPunycode($text)
{
    $pattern = '/(("mailto:)+[\\w\\.\\-\\+]+\\@[^"?]+\\.+[^."?]+("|\\?))/';
    if (preg_match_all($pattern, $text, $matches)) {
        foreach ($matches[0] as $match) {
            $match = (string) str_replace(array('?', '"'), '', $match);
            $text = (string) str_replace($match, PunycodeHelper::emailToPunycode($match), $text);
        }
    }
    return $text;
}