SimplePie_IRI::to_uri

Advertisement

Summery Summery

Convert an IRI to a URI (or parts thereof)

Syntax Syntax

SimplePie_IRI::to_uri( $string )

Return Return

(string)

Source Source

File: wp-includes/SimplePie/IRI.php

	public function to_uri($string)
	{
		static $non_ascii;
		if (!$non_ascii)
		{
			$non_ascii = implode('', range("\x80", "\xFF"));
		}

		$position = 0;
		$strlen = strlen($string);
		while (($position += strcspn($string, $non_ascii, $position)) < $strlen)
		{
			$string = substr_replace($string, sprintf('%%%02X', ord($string[$position])), $position, 1);
			$position += 3;
			$strlen += 2;
		}

		return $string;
	}

Advertisement

Advertisement

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.