Merged d00ps and my branch, renamed SysCP -> Froxlor in installer
This commit is contained in:
32
lib/functions/froxlor/function.convertUtf8.php
Normal file
32
lib/functions/froxlor/function.convertUtf8.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Florian Aders <eleras@froxlor.org>
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Convert a string to UTF-8 if needed
|
||||
* @param string String to be converted
|
||||
* @return string UTF-8 encoded string
|
||||
*
|
||||
* @author Florian Aders <eleras@froxlor.org>
|
||||
*/
|
||||
|
||||
function convertUtf8 ($string) {
|
||||
if (!isUtf8($string))
|
||||
{
|
||||
$string = utf8_encode($string);
|
||||
}
|
||||
return addslashes($string);
|
||||
}
|
||||
39
lib/functions/froxlor/function.isUtf8.php
Normal file
39
lib/functions/froxlor/function.isUtf8.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* Copyright (c) 2010 the Froxlor Team (see authors).
|
||||
*
|
||||
* For the full copyright and license information, please view the COPYING
|
||||
* file that was distributed with this source code. You can also view the
|
||||
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @author Florian Aders <eleras@froxlor.org>
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function which checks if a string is UTF8 encoded or not
|
||||
* @param string String to be checked
|
||||
* @return bool true if string is UTF8 encoded
|
||||
*
|
||||
* @author Florian Aders <eleras@froxlor.org>
|
||||
*/
|
||||
|
||||
function isUtf8 ($string) {
|
||||
// From http://w3.org/International/questions/qa-forms-utf-8.html
|
||||
return preg_match('%^(?:
|
||||
[\x09\x0A\x0D\x20-\x7E] # ASCII
|
||||
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
|
||||
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
|
||||
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
|
||||
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
|
||||
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
|
||||
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
|
||||
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
|
||||
)*$%xs', $string
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user