Version 3.2.3

This commit is contained in:
Neo committed 2025-12-19 00:34:03 -08:00
1 parent ae5c01cc78
commit 78706903a2
2641 files changed
+228363 -201264

No files matched your search

+25 -39
View File
@@ -3,25 +3,24 @@
/**
* <pre>
* Invision Power Services
* IP.Board v3.1.4
* IP.Board v3.2.3
* Character set conversion library
* Last Updated: $Date: 2010-05-07 19:47:45 -0400 (Fri, 07 May 2010) $
* Last Updated: $Date: 2011-09-07 14:34:13 -0400 (Wed, 07 Sep 2011) $
* </pre>
*
* @author $Author: bfarber $
* @author Mikolaj Jedrzejak <mikolajj@op.pl>
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @copyright Copyright Mikolaj Jedrzejak (c) 2003-2004
* @license http://www.invisionpower.com/community/board/license.html
* @license This is NULLED!
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @link http://hatynka.in
* @since Friday 2nd December 2005 10:18
* @version $Revision: 404 $
* @version $Revision: 9462 $
* @version 1.0 2004-07-27 00:37
* @link http://www.unicode.org Unicode Homepage
* @link http://www.mikkom.pl My Homepage
* @link https://www.invisionpower.com/index.php?appcomponent=downloads Downloads
*
* This class is an adaptation of the ConvertCharset.class.php provided by Mikolaj Jedrzejak.
* In order to use character set conversions, you must first download the conversion libraries from our website. See the 'Downloads' link.
@@ -51,7 +50,6 @@ class classConvertCharset
/**
* Array of error messages associated with the conversion
*
* @access public
* @var array Error messages
*/
public $errors = array();
@@ -59,16 +57,14 @@ class classConvertCharset
/**
* Should characters be turned into numeric entities
*
* @access private
* @var boolean
*/
private $entities = false;
protected $entities = false;
/**
* Conversion method to use.
* Valid values include: mb, iconv, recode, internal
*
* @access public
* @var string
*/
public $method = 'internal';
@@ -76,7 +72,6 @@ class classConvertCharset
/**
* Path for character sets
*
* @access public
* @var string
*/
public $charsetPath = '';
@@ -84,7 +79,6 @@ class classConvertCharset
/**
* Converts a text string from its current charset to a destination charset
*
* @access public
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
@@ -95,7 +89,8 @@ class classConvertCharset
$string_char_set = strtolower($string_char_set);
$t = $string;
if ( is_numeric( $t ) )
/* Return bools, null, ints, etc. */
if ( !is_string( $t ) )
{
return $t;
}
@@ -138,13 +133,12 @@ class classConvertCharset
/**
* Converts a text string from its current charset to a destination charset using mb_convert_encoding
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
private function convertUsing_mb( $string, $string_char_set, $destination_char_set='UTF-8' )
protected function convertUsing_mb( $string, $string_char_set, $destination_char_set='UTF-8' )
{
if ( function_exists( 'mb_convert_encoding' ) )
{
@@ -170,13 +164,12 @@ class classConvertCharset
/**
* Converts a text string from its current charset to a destination charset using iconv
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
private function convertUsing_iconv( $string, $string_char_set, $destination_char_set='UTF-8' )
protected function convertUsing_iconv( $string, $string_char_set, $destination_char_set='UTF-8' )
{
if ( function_exists( 'iconv' ) )
{
@@ -193,13 +186,12 @@ class classConvertCharset
/**
* Converts a text string from its current charset to a destination charset using recode_string
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
private function convertUsing_recode( $string, $string_char_set, $destination_char_set='UTF-8' )
protected function convertUsing_recode( $string, $string_char_set, $destination_char_set='UTF-8' )
{
if ( function_exists( 'recode_string' ) )
{
@@ -217,13 +209,12 @@ class classConvertCharset
* Converts a text string from its current charset to a destination charset using internal conversion class.
* The bulk of this function was written by Mikolaj Jedrzejak and used with permission via the License
*
* @access private
* @param string Text string
* @param string Text string char set (original)
* @param string Desired character set (destination)
* @return string Converted string
*/
private function convertUsing_internal( $string, $string_char_set, $destination_char_set='UTF-8' )
protected function convertUsing_internal( $string, $string_char_set, $destination_char_set='UTF-8' )
{
$text = '';
$original = $string;
@@ -239,12 +230,12 @@ class classConvertCharset
* encoding table to write proper entities.
*
* This is the first case. We are converting from 1byte chars...
**/
*/
if ($string_char_set != "utf-8")
{
/**
* Now build table with both charsets for encoding change.
**/
*/
if ($destination_char_set != "utf-8")
{
$charsetTable = $this->_makeConversionTable( $string_char_set, $destination_char_set );
@@ -262,7 +253,7 @@ class classConvertCharset
/**
* For each char in a string...
**/
*/
for ($i = 0; $i < strlen($string); $i++)
{
$hexChar = "";
@@ -332,7 +323,7 @@ class classConvertCharset
* The letters are merge with "plus" sign, there can be more than two chars.
* In Mazowia we have 007A+0142, but sometimes it can look like this
* 0x007A+0x0142+0x2034 (that string means nothing, it just shows the possibility...)
**/
*/
for( $unicodeHexCharElement = 0; $unicodeHexCharElement < count($unicodeHexChars); $unicodeHexCharElement++)
{
if ( $this->entities == true )
@@ -356,7 +347,7 @@ class classConvertCharset
/**
* This is second case. We are encoding from multibyte char string.
**/
*/
else if( $string_char_set == "utf-8" )
{
@@ -391,12 +382,11 @@ class classConvertCharset
/**
* Convert unicode characters to unicode HTML entities
*
* @access private
* @param string $unicodeString Input Unicode string (1 char can take more than 1 byte)
* @return string This is an input string also with unicode chars, but saved as entities
* @see _hexToUtf()
*/
private function _unicodeEntity( $unicodeString )
protected function _unicodeEntity( $unicodeString )
{
$outString = "";
$stringLength = strlen( $unicodeString );
@@ -468,12 +458,11 @@ class classConvertCharset
* It is very similar to _unicodeEntity function (link below). There is one difference
* in returned format. This time it's a regular char(s), in most cases it will be one or two chars.
*
* @access private
* @param string $utfCharInHex Hexadecimal value of a unicode char.
* @return string Encoded hexadecimal value as a regular char.
* @see _unicodeEntity()
*/
private function _hexToUtf( $utfCharInHex )
protected function _hexToUtf( $utfCharInHex )
{
$outputChar = "";
$utfCharInDec = hexdec($utfCharInHex);
@@ -530,12 +519,11 @@ class classConvertCharset
*
* You can get full tables with encodings from http://www.unicode.org
*
* @access private
* @param string $firstEncoding Name of first encoding and first encoding filename (thay have to be the same)
* @param string $secondEncoding Name of second encoding and second encoding filename (thay have to be the same). Optional for building a joined table.
* @return array Table necessary to change one encoding to another.
*/
private function _makeConversionTable( $firstEncoding, $secondEncoding = "" )
protected function _makeConversionTable( $firstEncoding, $secondEncoding = "" )
{
$convertTable = array();
@@ -544,7 +532,7 @@ class classConvertCharset
/**
* Because func_*** can't be used inside of another function call
* we have to save it as a separate value.
**/
*/
$fileName = func_get_arg($i);
if ( !is_file( $this->charsetPath . $fileName ) )
@@ -560,28 +548,26 @@ class classConvertCharset
/**
* We asume that line is not longer
* than 1024 which is the default value for fgets function
**/
*/
if( $oneLine = trim( fgets( $fileWithEncTabe, 1024 ) ) )
{
/**
* We don't need all comment lines. I check only for "#" sign, because
* this is a way of making comments by unicode.org in thair encoding files
* and that's where the files are from :-)
**/
*/
if ( substr( $oneLine, 0, 1 ) != "#" )
{
/**
* Sometimes inside the charset file the hex walues are separated by
* "space" and sometimes by "tab", the below preg_split can also be used
* to split files where separator is a ",", "\r", "\n" and "\f"
**/
*/
$hexValue = preg_split ( "/[\s,]+/", $oneLine, 3 ); //We need only first 2 values
/**
* Sometimes char is UNDEFINED, or missing so we can't use it for convertion
**/
*/
if (substr($hexValue[1], 0, 1) != "#")
{
$arrayKey = strtoupper(str_replace(strtolower("0x"), "", $hexValue[1]));