本文整理匯總了PHP中OC_Util::normalizeUnicode方法的典型用法代碼示例。如果您正苦於以下問題:PHP OC_Util::normalizeUnicode方法的具體用法?PHP OC_Util::normalizeUnicode怎麽用?PHP OC_Util::normalizeUnicode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OC_Util
的用法示例。
在下文中一共展示了OC_Util::normalizeUnicode方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: normalize
/**
* normalize the given path
*
* @param string $path
* @return string
*/
public function normalize($path)
{
return trim(\OC_Util::normalizeUnicode($path), '/');
}
示例2: normalize
/**
* normalize the given path
* @param $path
* @return string
*/
public function normalize($path)
{
return \OC_Util::normalizeUnicode($path);
}
示例3: normalizePath
/**
* Fix common problems with a file path
*
* @param string $path
* @param bool $stripTrailingSlash whether to strip the trailing slash
* @param bool $isAbsolutePath whether the given path is absolute
* @param bool $keepUnicode true to disable unicode normalization
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false, $keepUnicode = false)
{
if (is_null(self::$normalizedPathCache)) {
self::$normalizedPathCache = new CappedMemoryCache();
}
/**
* FIXME: This is a workaround for existing classes and files which call
* this function with another type than a valid string. This
* conversion should get removed as soon as all existing
* function calls have been fixed.
*/
$path = (string) $path;
$cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath]);
if (isset(self::$normalizedPathCache[$cacheKey])) {
return self::$normalizedPathCache[$cacheKey];
}
if ($path == '') {
return '/';
}
//normalize unicode if possible
if (!$keepUnicode) {
$path = \OC_Util::normalizeUnicode($path);
}
//no windows style slashes
$path = str_replace('\\', '/', $path);
//add leading slash
if ($path[0] !== '/') {
$path = '/' . $path;
}
// remove '/./'
// ugly, but str_replace() can't replace them all in one go
// as the replacement itself is part of the search string
// which will only be found during the next iteration
while (strpos($path, '/./') !== false) {
$path = str_replace('/./', '/', $path);
}
// remove sequences of slashes
$path = preg_replace('#/{2,}#', '/', $path);
//remove trailing slash
if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') {
$path = substr($path, 0, -1);
}
// remove trailing '/.'
if (substr($path, -2) == '/.') {
$path = substr($path, 0, -2);
}
$normalizedPath = $path;
self::$normalizedPathCache[$cacheKey] = $normalizedPath;
return $normalizedPath;
}
示例4: normalizePath
/**
* Fix common problems with a file path
*
* @param string $path
* @param bool $stripTrailingSlash
* @param bool $isAbsolutePath
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false)
{
/**
* FIXME: This is a workaround for existing classes and files which call
* this function with another type than a valid string. This
* conversion should get removed as soon as all existing
* function calls have been fixed.
*/
$path = (string) $path;
$cacheKey = json_encode([$path, $stripTrailingSlash, $isAbsolutePath]);
if (isset(self::$normalizedPathCache[$cacheKey])) {
return self::$normalizedPathCache[$cacheKey];
}
if ($path == '') {
return '/';
}
//normalize unicode if possible
$path = \OC_Util::normalizeUnicode($path);
//no windows style slashes
$path = str_replace('\\', '/', $path);
// When normalizing an absolute path, we need to ensure that the drive-letter
// is still at the beginning on windows
$windows_drive_letter = '';
if ($isAbsolutePath && \OC_Util::runningOnWindows() && preg_match('#^([a-zA-Z])$#', $path[0]) && $path[1] == ':' && $path[2] == '/') {
$windows_drive_letter = substr($path, 0, 2);
$path = substr($path, 2);
}
//add leading slash
if ($path[0] !== '/') {
$path = '/' . $path;
}
// remove '/./'
// ugly, but str_replace() can't replace them all in one go
// as the replacement itself is part of the search string
// which will only be found during the next iteration
while (strpos($path, '/./') !== false) {
$path = str_replace('/./', '/', $path);
}
// remove sequences of slashes
$path = preg_replace('#/{2,}#', '/', $path);
//remove trailing slash
if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') {
$path = substr($path, 0, -1);
}
// remove trailing '/.'
if (substr($path, -2) == '/.') {
$path = substr($path, 0, -2);
}
$normalizedPath = $windows_drive_letter . $path;
self::$normalizedPathCache[$cacheKey] = $normalizedPath;
return $normalizedPath;
}
示例5: normalizePath
/**
* Fix common problems with a file path
* @param string $path
* @param bool $stripTrailingSlash
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true, $isAbsolutePath = false)
{
if ($path == '') {
return '/';
}
//no windows style slashes
$path = str_replace('\\', '/', $path);
// When normalizing an absolute path, we need to ensure that the drive-letter
// is still at the beginning on windows
$windows_drive_letter = '';
if ($isAbsolutePath && \OC_Util::runningOnWindows() && preg_match('#^([a-zA-Z])$#', $path[0]) && $path[1] == ':' && $path[2] == '/') {
$windows_drive_letter = substr($path, 0, 2);
$path = substr($path, 2);
}
//add leading slash
if ($path[0] !== '/') {
$path = '/' . $path;
}
// remove '/./'
// ugly, but str_replace() can't replace them all in one go
// as the replacement itself is part of the search string
// which will only be found during the next iteration
while (strpos($path, '/./') !== false) {
$path = str_replace('/./', '/', $path);
}
// remove sequences of slashes
$path = preg_replace('#/{2,}#', '/', $path);
//remove trailing slash
if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') {
$path = substr($path, 0, -1);
}
// remove trailing '/.'
if (substr($path, -2) == '/.') {
$path = substr($path, 0, -2);
}
//normalize unicode if possible
$path = \OC_Util::normalizeUnicode($path);
return $windows_drive_letter . $path;
}
示例6: normalizePath
/**
* Fix common problems with a file path
* @param string $path
* @param bool $stripTrailingSlash
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true)
{
if ($path == '') {
return '/';
}
//no windows style slashes
$path = str_replace('\\', '/', $path);
//add leading slash
if ($path[0] !== '/') {
$path = '/' . $path;
}
// remove '/./'
// ugly, but str_replace() can't replace them all in one go
// as the replacement itself is part of the search string
// which will only be found during the next iteration
while (strpos($path, '/./') !== false) {
$path = str_replace('/./', '/', $path);
}
// remove sequences of slashes
$path = preg_replace('#/{2,}#', '/', $path);
//remove trailing slash
if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') {
$path = substr($path, 0, -1);
}
// remove trailing '/.'
if (substr($path, -2) == '/.') {
$path = substr($path, 0, -2);
}
//normalize unicode if possible
$path = \OC_Util::normalizeUnicode($path);
return $path;
}
示例7: normalizePath
/**
* @brief Fix common problems with a file path
* @param string $path
* @param bool $stripTrailingSlash
* @return string
*/
public static function normalizePath($path, $stripTrailingSlash = true)
{
/**
* FIXME: This is a workaround for existing classes and files which call
* this function with another type than a valid string. This
* conversion should get removed as soon as all existing
* function calls have been fixed.
*/
$path = (string) $path;
if ($path == '') {
return '/';
}
//normalize unicode if possible
$path = \OC_Util::normalizeUnicode($path);
//no windows style slashes
$path = str_replace('\\', '/', $path);
//add leading slash
if ($path[0] !== '/') {
$path = '/' . $path;
}
// remove '/./'
// ugly, but str_replace() can't replace them all in one go
// as the replacement itself is part of the search string
// which will only be found during the next iteration
while (strpos($path, '/./') !== false) {
$path = str_replace('/./', '/', $path);
}
// remove sequences of slashes
$path = preg_replace('#/{2,}#', '/', $path);
//remove trailing slash
if ($stripTrailingSlash and strlen($path) > 1 and substr($path, -1, 1) === '/') {
$path = substr($path, 0, -1);
}
// remove trailing '/.'
if (substr($path, -2) == '/.') {
$path = substr($path, 0, -2);
}
return $path;
}