ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
PHPExcel_Shared_String Class Reference
+ Collaboration diagram for PHPExcel_Shared_String:

Static Public Member Functions

static getIsMbstringEnabled ()
 Get whether mbstring extension is available.
static getIsIconvEnabled ()
 Get whether iconv extension is available.
static ControlCharacterOOXML2PHP ($value= '')
 Convert from OpenXML escaped control character to PHP control character.
static ControlCharacterPHP2OOXML ($value= '')
 Convert from PHP control character to OpenXML escaped control character.
static SanitizeUTF8 ($value)
 Try to sanitize UTF8, stripping invalid byte sequences.
static IsUTF8 ($value= '')
 Check if a string contains UTF8 data.
static FormatNumber ($value)
 Formats a numeric value as a string for output in various output writers forcing point as decimal separator in case locale is other than English.
static UTF8toBIFF8UnicodeShort ($value)
 Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) Writes the string using uncompressed notation, no rich text, no Asian phonetics If mbstring extension is not available, ASCII is assumed, and compressed notation is used although this will give wrong results for non-ASCII strings see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect.
static UTF8toBIFF8UnicodeLong ($value)
 Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) Writes the string using uncompressed notation, no rich text, no Asian phonetics If mbstring extension is not available, ASCII is assumed, and compressed notation is used although this will give wrong results for non-ASCII strings see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect.
static ConvertEncoding ($value, $to, $from)
 Convert string from one encoding to another.
static CountCharacters ($value, $enc= 'UTF-8')
 Get character count.
static Substring ($pValue= '', $pStart=0, $pLength=0)
 Get a substring of a UTF-8 encoded string.

Static Private Member Functions

static _buildControlCharacters ()
 Build control characters array.

Static Private Attributes

static $_controlCharacters = array()
static $_isMbstringEnabled
static $_isIconvEnabled

Detailed Description

Definition at line 36 of file String.php.

Member Function Documentation

static PHPExcel_Shared_String::_buildControlCharacters ( )
staticprivate

Build control characters array.

Definition at line 62 of file String.php.

Referenced by ControlCharacterOOXML2PHP(), and ControlCharacterPHP2OOXML().

{
for ($i = 0; $i <= 19; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) {
$find = '_x' . sprintf('%04s' , strtoupper(dechex($i))) . '_';
$replace = chr($i);
self::$_controlCharacters[$find] = $replace;
}
}
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::ControlCharacterOOXML2PHP (   $value = '')
static

Convert from OpenXML escaped control character to PHP control character.

Excel 2007 team:

That's correct, control characters are stored directly in the shared-strings table. We do encode characters that cannot be represented in XML using the following escape sequence: xHHHH where H represents a hexadecimal character in the character's value... So you could end up with something like x0008 in a string (either in a cell value (<v>) element or in the shared string <t> element.

Parameters
string$valueValue to unescape
Returns
string

Definition at line 120 of file String.php.

References _buildControlCharacters().

Referenced by PHPExcel_Reader_Excel2007\_parseRichText(), and PHPExcel_Reader_Excel2007\load().

{
if(empty(self::$_controlCharacters)) {
}
return str_replace( array_keys(self::$_controlCharacters), array_values(self::$_controlCharacters), $value );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::ControlCharacterPHP2OOXML (   $value = '')
static

Convert from PHP control character to OpenXML escaped control character.

Excel 2007 team:

That's correct, control characters are stored directly in the shared-strings table. We do encode characters that cannot be represented in XML using the following escape sequence: xHHHH where H represents a hexadecimal character in the character's value... So you could end up with something like x0008 in a string (either in a cell value (<v>) element or in the shared string <t> element.

Parameters
string$valueValue to escape
Returns
string

Definition at line 142 of file String.php.

References _buildControlCharacters().

Referenced by PHPExcel_Writer_Excel2007_Worksheet\_writeCell(), PHPExcel_Writer_Excel2007_StringTable\writeRichText(), and PHPExcel_Writer_Excel2007_StringTable\writeStringTable().

{
if(empty(self::$_controlCharacters)) {
}
return str_replace( array_values(self::$_controlCharacters), array_keys(self::$_controlCharacters), $value );
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::ConvertEncoding (   $value,
  $to,
  $from 
)
static

Convert string from one encoding to another.

First try mbstring, then iconv, or no convertion

Parameters
string$value
string$toEncoding to convert to, e.g. 'UTF-8'
string$fromEncoding to convert from, e.g. 'UTF-16LE'
Returns
string

Definition at line 256 of file String.php.

Referenced by PHPExcel_Reader_Excel5\_decodeCodepage(), PHPExcel_Reader_Excel5\_encodeUTF16(), PHPExcel_Writer_Excel5_Worksheet\_writeUrlInternal(), UTF8toBIFF8UnicodeLong(), and UTF8toBIFF8UnicodeShort().

{
if (self::getIsIconvEnabled()) {
$value = iconv($from, $to, $value);
return $value;
}
if (self::getIsMbstringEnabled()) {
$value = mb_convert_encoding($value, $to, $from);
return $value;
}
// else, no conversion
return $value;
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::CountCharacters (   $value,
  $enc = 'UTF-8' 
)
static

Get character count.

First try mbstring, then iconv, finally strlen

Parameters
string$value
string$encEncoding
Returns
int Character count

Definition at line 279 of file String.php.

References $enc.

Referenced by PHPExcel_Writer_Excel5_Workbook\_writeDefinedNameBiff8(), PHPExcel_Writer_Excel5_Worksheet\_writeUrlInternal(), PHPExcel_Worksheet\setTitle(), UTF8toBIFF8UnicodeLong(), and UTF8toBIFF8UnicodeShort().

{
if (self::getIsIconvEnabled()) {
$count = iconv_strlen($value, $enc);
return $count;
}
if (self::getIsMbstringEnabled()) {
$count = mb_strlen($value, $enc);
return $count;
}
// else strlen
$count = strlen($value);
return $count;
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::FormatNumber (   $value)
static

Formats a numeric value as a string for output in various output writers forcing point as decimal separator in case locale is other than English.

Parameters
mixed$value
Returns
string

Definition at line 189 of file String.php.

Referenced by PHPExcel_Writer_Excel2007_Worksheet\_writeCell(), PHPExcel_Writer_Excel2007_Worksheet\_writeCols(), PHPExcel_Writer_Excel2007_Worksheet\_writePageMargins(), PHPExcel_Writer_Excel2007_Worksheet\_writeSheetData(), and PHPExcel_Writer_Excel2007_Worksheet\_writeSheetFormatPr().

{
if (is_float($value)) {
return str_replace(',', '.', $value);
}
return (string) $value;
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::getIsIconvEnabled ( )
static

Get whether iconv extension is available.

Returns
boolean

Definition at line 94 of file String.php.

References $_isIconvEnabled.

Referenced by UTF8toBIFF8UnicodeLong(), and UTF8toBIFF8UnicodeShort().

{
if (isset(self::$_isIconvEnabled)) {
}
self::$_isIconvEnabled = function_exists('iconv') ?
true : false;
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::getIsMbstringEnabled ( )
static

Get whether mbstring extension is available.

Returns
boolean

Definition at line 77 of file String.php.

References $_isMbstringEnabled.

Referenced by UTF8toBIFF8UnicodeLong(), and UTF8toBIFF8UnicodeShort().

{
if (isset(self::$_isMbstringEnabled)) {
}
self::$_isMbstringEnabled = function_exists('mb_convert_encoding') ?
true : false;
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::IsUTF8 (   $value = '')
static

Check if a string contains UTF8 data.

Parameters
string$value
Returns
boolean

Definition at line 178 of file String.php.

{
return utf8_encode(utf8_decode($value)) === $value;
}
static PHPExcel_Shared_String::SanitizeUTF8 (   $value)
static

Try to sanitize UTF8, stripping invalid byte sequences.

Not perfect. Does not surrogate characters.

Parameters
string$value
Returns
string

Definition at line 156 of file String.php.

Referenced by PHPExcel_Cell_DefaultValueBinder\bindValue(), and PHPExcel_Cell_AdvancedValueBinder\bindValue().

{
if (self::getIsIconvEnabled()) {
$value = @iconv('UTF-8', 'UTF-8', $value);
return $value;
}
if (self::getIsMbstringEnabled()) {
$value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
return $value;
}
// else, no conversion
return $value;
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::Substring (   $pValue = '',
  $pStart = 0,
  $pLength = 0 
)
static

Get a substring of a UTF-8 encoded string.

Parameters
string$pValueUTF-8 encoded string
int$startStart offset
int$lengthMaximum number of characters in substring
Returns
string

Definition at line 304 of file String.php.

Referenced by PHPExcel_Cell\setValueExplicit().

{
if (self::getIsIconvEnabled()) {
$string = iconv_substr($pValue, $pStart, $pLength, 'UTF-8');
return $string;
}
if (self::getIsMbstringEnabled()) {
$string = mb_substr($pValue, $pStart, $pLength, 'UTF-8');
return $string;
}
// else substr
$string = substr($pValue, $pStart, $pLength);
return $string;
}

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong (   $value)
static

Converts a UTF-8 string into BIFF8 Unicode string data (16-bit string length) Writes the string using uncompressed notation, no rich text, no Asian phonetics If mbstring extension is not available, ASCII is assumed, and compressed notation is used although this will give wrong results for non-ASCII strings see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect.

2.5.3

Parameters
string$valueUTF-8 encoded string
Returns
string

Definition at line 232 of file String.php.

References $data, ConvertEncoding(), CountCharacters(), getIsIconvEnabled(), and getIsMbstringEnabled().

Referenced by PHPExcel_Writer_Excel5_Worksheet\_storeFooter(), PHPExcel_Writer_Excel5_Worksheet\_storeHeader(), PHPExcel_Writer_Excel5_Workbook\_storeNumFormat(), PHPExcel_Writer_Excel5_Worksheet\_storeRangeProtection(), PHPExcel_Writer_Excel5_Workbook\_writeDefinedNameBiff8(), and PHPExcel_Writer_Excel5_Worksheet\_writeLabelSst().

{
// character count
$ln = self::CountCharacters($value, 'UTF-8');
// option flags
0x0001 : 0x0000;
// characters
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
$data = pack('vC', $ln, $opt) . $chars;
return $data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static PHPExcel_Shared_String::UTF8toBIFF8UnicodeShort (   $value)
static

Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length) Writes the string using uncompressed notation, no rich text, no Asian phonetics If mbstring extension is not available, ASCII is assumed, and compressed notation is used although this will give wrong results for non-ASCII strings see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect.

2.5.3

Parameters
string$valueUTF-8 encoded string
Returns
string

Definition at line 206 of file String.php.

References $data, ConvertEncoding(), CountCharacters(), getIsIconvEnabled(), and getIsMbstringEnabled().

Referenced by PHPExcel_Writer_Excel5_Workbook\_calcSheetOffsets(), PHPExcel_Writer_Excel5_Parser\_convertString(), PHPExcel_Writer_Excel5_Workbook\_storeBoundsheet(), and PHPExcel_Writer_Excel5_Font\writeFont().

{
// character count
$ln = self::CountCharacters($value, 'UTF-8');
// option flags
0x0001 : 0x0000;
// characters
$chars = self::ConvertEncoding($value, 'UTF-16LE', 'UTF-8');
$data = pack('CC', $ln, $opt) . $chars;
return $data;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

PHPExcel_Shared_String::$_controlCharacters = array()
staticprivate

Definition at line 43 of file String.php.

PHPExcel_Shared_String::$_isIconvEnabled
staticprivate

Definition at line 57 of file String.php.

Referenced by getIsIconvEnabled().

PHPExcel_Shared_String::$_isMbstringEnabled
staticprivate

Definition at line 50 of file String.php.

Referenced by getIsMbstringEnabled().


The documentation for this class was generated from the following file: