Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
@@ -1,20 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* IP.Board v3.1.4
|
||||
* Character set conversion library
|
||||
* Last Updated: $Date: 2009-09-25 07:10:57 -0400 (Fri, 25 Sep 2009) $
|
||||
* Last Updated: $Date: 2010-05-07 19:47:45 -0400 (Fri, 07 May 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: matt $
|
||||
* @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.iinvisionpower.com/community/board/license.html
|
||||
* @package Invision Power Services Kernel
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @package IP.Board
|
||||
* @subpackage Kernel
|
||||
* @link http://www.invisionpower.com
|
||||
* @since Friday 2nd December 2005 10:18
|
||||
* @version $Revision: 328 $
|
||||
* @version $Revision: 404 $
|
||||
* @version 1.0 2004-07-27 00:37
|
||||
* @link http://www.unicode.org Unicode Homepage
|
||||
* @link http://www.mikkom.pl My Homepage
|
||||
@@ -46,47 +49,47 @@ if ( ! defined( 'IPS_CLASSES_PATH' ) )
|
||||
class classConvertCharset
|
||||
{
|
||||
/**
|
||||
* Array of error messages associated with the conversion
|
||||
*
|
||||
* @access public
|
||||
* @var array Error messages
|
||||
*/
|
||||
* Array of error messages associated with the conversion
|
||||
*
|
||||
* @access public
|
||||
* @var array Error messages
|
||||
*/
|
||||
public $errors = array();
|
||||
|
||||
/**
|
||||
* Should characters be turned into numeric entities
|
||||
*
|
||||
* @access private
|
||||
* @var boolean
|
||||
*/
|
||||
* Should characters be turned into numeric entities
|
||||
*
|
||||
* @access private
|
||||
* @var boolean
|
||||
*/
|
||||
private $entities = false;
|
||||
|
||||
/**
|
||||
* Conversion method to use.
|
||||
* Valid values include: mb, iconv, recode, internal
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
* Conversion method to use.
|
||||
* Valid values include: mb, iconv, recode, internal
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $method = 'internal';
|
||||
|
||||
/**
|
||||
* Path for character sets
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
* Path for character sets
|
||||
*
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $charsetPath = '';
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @return string Converted string
|
||||
*/
|
||||
* 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)
|
||||
* @return string Converted string
|
||||
*/
|
||||
public function convertEncoding( $string, $string_char_set, $destination_char_set='UTF-8' )
|
||||
{
|
||||
$string_char_set = strtolower($string_char_set);
|
||||
@@ -133,14 +136,14 @@ 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
|
||||
*/
|
||||
* 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' )
|
||||
{
|
||||
if ( function_exists( 'mb_convert_encoding' ) )
|
||||
@@ -165,14 +168,14 @@ 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
|
||||
*/
|
||||
* 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' )
|
||||
{
|
||||
if ( function_exists( 'iconv' ) )
|
||||
@@ -188,14 +191,14 @@ 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
|
||||
*/
|
||||
* 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' )
|
||||
{
|
||||
if ( function_exists( 'recode_string' ) )
|
||||
@@ -211,15 +214,15 @@ 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
|
||||
*/
|
||||
* 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' )
|
||||
{
|
||||
$text = '';
|
||||
@@ -235,15 +238,15 @@ class classConvertCharset
|
||||
* "entities" enabled, because we need to use proper destination(to)/source(from)
|
||||
* encoding table to write proper entities.
|
||||
*
|
||||
* This is the first case. We are convertinf from 1byte chars...
|
||||
* 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 );
|
||||
}
|
||||
else
|
||||
@@ -390,9 +393,9 @@ class classConvertCharset
|
||||
*
|
||||
* @access private
|
||||
* @param string $unicodeString Input Unicode string (1 char can take more than 1 byte)
|
||||
* @return string This is an input string olso with unicode chars, bus saved as entities
|
||||
* @return string This is an input string also with unicode chars, but saved as entities
|
||||
* @see _hexToUtf()
|
||||
**/
|
||||
*/
|
||||
private function _unicodeEntity( $unicodeString )
|
||||
{
|
||||
$outString = "";
|
||||
@@ -469,7 +472,7 @@ class classConvertCharset
|
||||
* @param string $utfCharInHex Hexadecimal value of a unicode char.
|
||||
* @return string Encoded hexadecimal value as a regular char.
|
||||
* @see _unicodeEntity()
|
||||
**/
|
||||
*/
|
||||
private function _hexToUtf( $utfCharInHex )
|
||||
{
|
||||
$outputChar = "";
|
||||
@@ -531,7 +534,7 @@ class classConvertCharset
|
||||
* @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 = "" )
|
||||
{
|
||||
$convertTable = array();
|
||||
@@ -593,6 +596,4 @@ class classConvertCharset
|
||||
|
||||
return $convertTable;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
||||
Reference in new issue
Block a user