Created
June 7, 2011 11:00
-
-
Save moustaki/1012034 to your computer and use it in GitHub Desktop.
Handle IRIs with Zend_Uri
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts to a Zend_Uri object | |
* @protected | |
* @static | |
* @param string $s | |
* @return Zend_Uri | |
*/ | |
protected static function uri($s) | |
{ | |
if (!empty($s)) { | |
Zend_Uri::setConfig(array('allow_unwise' => true)); | |
$ignore = Zend_Uri_Http::CHAR_ALNUM; | |
$ignore .= Zend_Uri_Http::CHAR_MARK; | |
$ignore .= Zend_Uri_Http::CHAR_RESERVED; | |
$ignore .= Zend_Uri_Http::CHAR_SEGMENT; | |
$s = preg_replace('{([^'. $ignore . '])}e', 'sprintf("%%%02X", ord("$1"))', $s); | |
return Zend_Uri::factory($s); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment