| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/a/w/e/awebpaca/Dolibarr/htdocs/includes/sabre/sabre/vobject/lib/ |
Upload File : |
<?php
namespace Sabre\VObject;
/**
* Useful utilities for working with various strings.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class StringUtil
{
/**
* Returns true or false depending on if a string is valid UTF-8.
*
* @param string $str
*
* @return bool
*/
public static function isUTF8($str)
{
// Control characters
if (preg_match('%[\x00-\x08\x0B-\x0C\x0E\x0F]%', $str)) {
return false;
}
return (bool) preg_match('%%u', $str);
}
/**
* This method tries its best to convert the input string to UTF-8.
*
* Currently only ISO-5991-1 input and UTF-8 input is supported, but this
* may be expanded upon if we receive other examples.
*
* @param string $str
*
* @return string
*/
public static function convertToUTF8($str)
{
if (!mb_check_encoding($str, 'UTF-8') && mb_check_encoding($str, 'ISO-8859-1')) {
$str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1');
}
// Removing any control characters
return preg_replace('%(?:[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F])%', '', $str);
}
}