StringHelper
in package
Table of Contents
Constants
- CONTROL_CHARACTERS_KEYS = ["\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\t", "\n", "\v", "\f", "\r", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f"]
- CONTROL_CHARACTERS_VALUES = ['_x0000_', '_x0001_', '_x0002_', '_x0003_', '_x0004_', '_x0005_', '_x0006_', '_x0007_', '_x0008_', '_x0009_', '_x000A_', '_x000B_', '_x000C_', '_x000D_', '_x000E_', '_x000F_', '_x0010_', '_x0011_', '_x0012_', '_x0013_', '_x0014_', '_x0015_', '_x0016_', '_x0017_', '_x0018_', '_x0019_', '_x001A_', '_x001B_', '_x001C_', '_x001D_', '_x001E_', '_x001F_']
- SYLK_CHARACTERS = [ "\x1b 0" => "\x00", "\x1b 1" => "\x01", "\x1b 2" => "\x02", "\x1b 3" => "\x03", "\x1b 4" => "\x04", "\x1b 5" => "\x05", "\x1b 6" => "\x06", "\x1b 7" => "\x07", "\x1b 8" => "\x08", "\x1b 9" => "\t", "\x1b :" => "\n", "\x1b ;" => "\v", "\x1b <" => "\f", "\x1b =" => "\r", "\x1b >" => "\x0e", "\x1b ?" => "\x0f", "\x1b!0" => "\x10", "\x1b!1" => "\x11", "\x1b!2" => "\x12", "\x1b!3" => "\x13", "\x1b!4" => "\x14", "\x1b!5" => "\x15", "\x1b!6" => "\x16", "\x1b!7" => "\x17", "\x1b!8" => "\x18", "\x1b!9" => "\x19", "\x1b!:" => "\x1a", "\x1b!;" => "\x1b", "\x1b!<" => "\x1c", "\x1b!=" => "\x1d", "\x1b!>" => "\x1e", "\x1b!?" => "\x1f", "\x1b'?" => "", "\x1b(0" => '€', // 128 in CP1252 "\x1b(2" => '‚', // 130 in CP1252 "\x1b(3" => 'ƒ', // 131 in CP1252 "\x1b(4" => '„', // 132 in CP1252 "\x1b(5" => '…', // 133 in CP1252 "\x1b(6" => '†', // 134 in CP1252 "\x1b(7" => '‡', // 135 in CP1252 "\x1b(8" => 'ˆ', // 136 in CP1252 "\x1b(9" => '‰', // 137 in CP1252 "\x1b(:" => 'Š', // 138 in CP1252 "\x1b(;" => '‹', // 139 in CP1252 "\x1bNj" => 'Œ', // 140 in CP1252 "\x1b(>" => 'Ž', // 142 in CP1252 "\x1b)1" => '‘', // 145 in CP1252 "\x1b)2" => '’', // 146 in CP1252 "\x1b)3" => '“', // 147 in CP1252 "\x1b)4" => '”', // 148 in CP1252 "\x1b)5" => '•', // 149 in CP1252 "\x1b)6" => '–', // 150 in CP1252 "\x1b)7" => '—', // 151 in CP1252 "\x1b)8" => '˜', // 152 in CP1252 "\x1b)9" => '™', // 153 in CP1252 "\x1b):" => 'š', // 154 in CP1252 "\x1b);" => '›', // 155 in CP1252 "\x1bNz" => 'œ', // 156 in CP1252 "\x1b)>" => 'ž', // 158 in CP1252 "\x1b)?" => 'Ÿ', // 159 in CP1252 "\x1b*0" => ' ', // 160 in CP1252 "\x1bN!" => '¡', // 161 in CP1252 "\x1bN\"" => '¢', // 162 in CP1252 "\x1bN#" => '£', // 163 in CP1252 "\x1bN(" => '¤', // 164 in CP1252 "\x1bN%" => '¥', // 165 in CP1252 "\x1b*6" => '¦', // 166 in CP1252 "\x1bN'" => '§', // 167 in CP1252 "\x1bNH " => '¨', // 168 in CP1252 "\x1bNS" => '©', // 169 in CP1252 "\x1bNc" => 'ª', // 170 in CP1252 "\x1bN+" => '«', // 171 in CP1252 "\x1b*<" => '¬', // 172 in CP1252 "\x1b*=" => '', // 173 in CP1252 "\x1bNR" => '®', // 174 in CP1252 "\x1b*?" => '¯', // 175 in CP1252 "\x1bN0" => '°', // 176 in CP1252 "\x1bN1" => '±', // 177 in CP1252 "\x1bN2" => '²', // 178 in CP1252 "\x1bN3" => '³', // 179 in CP1252 "\x1bNB " => '´', // 180 in CP1252 "\x1bN5" => 'µ', // 181 in CP1252 "\x1bN6" => '¶', // 182 in CP1252 "\x1bN7" => '·', // 183 in CP1252 "\x1b+8" => '¸', // 184 in CP1252 "\x1bNQ" => '¹', // 185 in CP1252 "\x1bNk" => 'º', // 186 in CP1252 "\x1bN;" => '»', // 187 in CP1252 "\x1bN<" => '¼', // 188 in CP1252 "\x1bN=" => '½', // 189 in CP1252 "\x1bN>" => '¾', // 190 in CP1252 "\x1bN?" => '¿', // 191 in CP1252 "\x1bNAA" => 'À', // 192 in CP1252 "\x1bNBA" => 'Á', // 193 in CP1252 "\x1bNCA" => 'Â', // 194 in CP1252 "\x1bNDA" => 'Ã', // 195 in CP1252 "\x1bNHA" => 'Ä', // 196 in CP1252 "\x1bNJA" => 'Å', // 197 in CP1252 "\x1bNa" => 'Æ', // 198 in CP1252 "\x1bNKC" => 'Ç', // 199 in CP1252 "\x1bNAE" => 'È', // 200 in CP1252 "\x1bNBE" => 'É', // 201 in CP1252 "\x1bNCE" => 'Ê', // 202 in CP1252 "\x1bNHE" => 'Ë', // 203 in CP1252 "\x1bNAI" => 'Ì', // 204 in CP1252 "\x1bNBI" => 'Í', // 205 in CP1252 "\x1bNCI" => 'Î', // 206 in CP1252 "\x1bNHI" => 'Ï', // 207 in CP1252 "\x1bNb" => 'Ð', // 208 in CP1252 "\x1bNDN" => 'Ñ', // 209 in CP1252 "\x1bNAO" => 'Ò', // 210 in CP1252 "\x1bNBO" => 'Ó', // 211 in CP1252 "\x1bNCO" => 'Ô', // 212 in CP1252 "\x1bNDO" => 'Õ', // 213 in CP1252 "\x1bNHO" => 'Ö', // 214 in CP1252 "\x1b-7" => '×', // 215 in CP1252 "\x1bNi" => 'Ø', // 216 in CP1252 "\x1bNAU" => 'Ù', // 217 in CP1252 "\x1bNBU" => 'Ú', // 218 in CP1252 "\x1bNCU" => 'Û', // 219 in CP1252 "\x1bNHU" => 'Ü', // 220 in CP1252 "\x1b-=" => 'Ý', // 221 in CP1252 "\x1bNl" => 'Þ', // 222 in CP1252 "\x1bN{" => 'ß', // 223 in CP1252 "\x1bNAa" => 'à', // 224 in CP1252 "\x1bNBa" => 'á', // 225 in CP1252 "\x1bNCa" => 'â', // 226 in CP1252 "\x1bNDa" => 'ã', // 227 in CP1252 "\x1bNHa" => 'ä', // 228 in CP1252 "\x1bNJa" => 'å', // 229 in CP1252 "\x1bNq" => 'æ', // 230 in CP1252 "\x1bNKc" => 'ç', // 231 in CP1252 "\x1bNAe" => 'è', // 232 in CP1252 "\x1bNBe" => 'é', // 233 in CP1252 "\x1bNCe" => 'ê', // 234 in CP1252 "\x1bNHe" => 'ë', // 235 in CP1252 "\x1bNAi" => 'ì', // 236 in CP1252 "\x1bNBi" => 'í', // 237 in CP1252 "\x1bNCi" => 'î', // 238 in CP1252 "\x1bNHi" => 'ï', // 239 in CP1252 "\x1bNs" => 'ð', // 240 in CP1252 "\x1bNDn" => 'ñ', // 241 in CP1252 "\x1bNAo" => 'ò', // 242 in CP1252 "\x1bNBo" => 'ó', // 243 in CP1252 "\x1bNCo" => 'ô', // 244 in CP1252 "\x1bNDo" => 'õ', // 245 in CP1252 "\x1bNHo" => 'ö', // 246 in CP1252 "\x1b/7" => '÷', // 247 in CP1252 "\x1bNy" => 'ø', // 248 in CP1252 "\x1bNAu" => 'ù', // 249 in CP1252 "\x1bNBu" => 'ú', // 250 in CP1252 "\x1bNCu" => 'û', // 251 in CP1252 "\x1bNHu" => 'ü', // 252 in CP1252 "\x1b/=" => 'ý', // 253 in CP1252 "\x1bN|" => 'þ', // 254 in CP1252 "\x1bNHy" => 'ÿ', ]
- SYLK Characters array.
Properties
- $currencyCode : string|null
- Currency code.
- $decimalSeparator : string|null
- Decimal separator.
- $iconvOptions : string
- iconv options.
- $isIconvEnabled : bool|null
- Is iconv extension avalable?
- $thousandsSeparator : string|null
- Thousands separator.
Methods
- controlCharacterOOXML2PHP() : string
- Convert from OpenXML escaped control character to PHP control character.
- controlCharacterPHP2OOXML() : string
- Convert from PHP control character to OpenXML escaped control character.
- convertEncoding() : string
- Convert string from one encoding to another.
- convertPostToString() : string
- Assist with POST items when samples are run in browser.
- convertToString() : string
- countCharacters() : int
- Get character count.
- countCharactersDbcs() : int
- Get character count using mb_strwidth rather than mb_strlen.
- formatNumber() : string
- 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.
- getCurrencyCode() : string
- Get the currency code. If it has not yet been set explicitly, try to obtain the symbol information from locale.
- getDecimalSeparator() : string
- Get the decimal separator. If it has not yet been set explicitly, try to obtain number formatting information from locale.
- getIsIconvEnabled() : bool
- Get whether iconv extension is available.
- getThousandsSeparator() : string
- Get the thousands separator. If it has not yet been set explicitly, try to obtain number formatting information from locale.
- isUTF8() : bool
- Check if a string contains UTF8 data.
- mbIsUpper() : bool
- mbStrSplit() : array<string|int, string>
- Splits a UTF-8 string into an array of individual characters.
- sanitizeUTF8() : string
- Try to sanitize UTF8, replacing invalid sequences with Unicode substitution characters.
- setCurrencyCode() : void
- Set the currency code. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.
- setDecimalSeparator() : void
- Set the decimal separator. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.
- setThousandsSeparator() : void
- Set the thousands separator. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.
- strCaseReverse() : string
- Reverse the case of a string, so that all uppercase characters become lowercase and all lowercase characters become uppercase.
- strlenAllowNull() : int
- strToLower() : string
- Convert a UTF-8 encoded string to lower case.
- strToTitle() : string
- Convert a UTF-8 encoded string to title/proper case (uppercase every first character in each word, lower case all other characters).
- strToUpper() : string
- Convert a UTF-8 encoded string to upper case.
- substring() : string
- Get a substring of a UTF-8 encoded string.
- SYLKtoUTF8() : string
- Convert SYLK encoded string to UTF-8.
- testStringAsNumeric() : float|string
- Retrieve any leading numeric part of a string, or return the full string if no leading numeric (handles basic integer or float, but not exponent or non decimal).
- UTF8toBIFF8UnicodeLong() : string
- 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.
- UTF8toBIFF8UnicodeShort() : string
- 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.
- getLocaleValue() : string
- useAlt() : string
Constants
CONTROL_CHARACTERS_KEYS
private
mixed
CONTROL_CHARACTERS_KEYS
= ["\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07", "\x08", "\t", "\n", "\v", "\f", "\r", "\x0e", "\x0f", "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17", "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f"]
CONTROL_CHARACTERS_VALUES
private
mixed
CONTROL_CHARACTERS_VALUES
= ['_x0000_', '_x0001_', '_x0002_', '_x0003_', '_x0004_', '_x0005_', '_x0006_', '_x0007_', '_x0008_', '_x0009_', '_x000A_', '_x000B_', '_x000C_', '_x000D_', '_x000E_', '_x000F_', '_x0010_', '_x0011_', '_x0012_', '_x0013_', '_x0014_', '_x0015_', '_x0016_', '_x0017_', '_x0018_', '_x0019_', '_x001A_', '_x001B_', '_x001C_', '_x001D_', '_x001E_', '_x001F_']
SYLK_CHARACTERS
SYLK Characters array.
private
mixed
SYLK_CHARACTERS
= [
"\x1b 0" => "\x00",
"\x1b 1" => "\x01",
"\x1b 2" => "\x02",
"\x1b 3" => "\x03",
"\x1b 4" => "\x04",
"\x1b 5" => "\x05",
"\x1b 6" => "\x06",
"\x1b 7" => "\x07",
"\x1b 8" => "\x08",
"\x1b 9" => "\t",
"\x1b :" => "\n",
"\x1b ;" => "\v",
"\x1b <" => "\f",
"\x1b =" => "\r",
"\x1b >" => "\x0e",
"\x1b ?" => "\x0f",
"\x1b!0" => "\x10",
"\x1b!1" => "\x11",
"\x1b!2" => "\x12",
"\x1b!3" => "\x13",
"\x1b!4" => "\x14",
"\x1b!5" => "\x15",
"\x1b!6" => "\x16",
"\x1b!7" => "\x17",
"\x1b!8" => "\x18",
"\x1b!9" => "\x19",
"\x1b!:" => "\x1a",
"\x1b!;" => "\x1b",
"\x1b!<" => "\x1c",
"\x1b!=" => "\x1d",
"\x1b!>" => "\x1e",
"\x1b!?" => "\x1f",
"\x1b'?" => "",
"\x1b(0" => '€',
// 128 in CP1252
"\x1b(2" => '‚',
// 130 in CP1252
"\x1b(3" => 'ƒ',
// 131 in CP1252
"\x1b(4" => '„',
// 132 in CP1252
"\x1b(5" => '…',
// 133 in CP1252
"\x1b(6" => '†',
// 134 in CP1252
"\x1b(7" => '‡',
// 135 in CP1252
"\x1b(8" => 'ˆ',
// 136 in CP1252
"\x1b(9" => '‰',
// 137 in CP1252
"\x1b(:" => 'Š',
// 138 in CP1252
"\x1b(;" => '‹',
// 139 in CP1252
"\x1bNj" => 'Œ',
// 140 in CP1252
"\x1b(>" => 'Ž',
// 142 in CP1252
"\x1b)1" => '‘',
// 145 in CP1252
"\x1b)2" => '’',
// 146 in CP1252
"\x1b)3" => '“',
// 147 in CP1252
"\x1b)4" => '”',
// 148 in CP1252
"\x1b)5" => '•',
// 149 in CP1252
"\x1b)6" => '–',
// 150 in CP1252
"\x1b)7" => '—',
// 151 in CP1252
"\x1b)8" => '˜',
// 152 in CP1252
"\x1b)9" => '™',
// 153 in CP1252
"\x1b):" => 'š',
// 154 in CP1252
"\x1b);" => '›',
// 155 in CP1252
"\x1bNz" => 'œ',
// 156 in CP1252
"\x1b)>" => 'ž',
// 158 in CP1252
"\x1b)?" => 'Ÿ',
// 159 in CP1252
"\x1b*0" => ' ',
// 160 in CP1252
"\x1bN!" => '¡',
// 161 in CP1252
"\x1bN\"" => '¢',
// 162 in CP1252
"\x1bN#" => '£',
// 163 in CP1252
"\x1bN(" => '¤',
// 164 in CP1252
"\x1bN%" => '¥',
// 165 in CP1252
"\x1b*6" => '¦',
// 166 in CP1252
"\x1bN'" => '§',
// 167 in CP1252
"\x1bNH " => '¨',
// 168 in CP1252
"\x1bNS" => '©',
// 169 in CP1252
"\x1bNc" => 'ª',
// 170 in CP1252
"\x1bN+" => '«',
// 171 in CP1252
"\x1b*<" => '¬',
// 172 in CP1252
"\x1b*=" => '',
// 173 in CP1252
"\x1bNR" => '®',
// 174 in CP1252
"\x1b*?" => '¯',
// 175 in CP1252
"\x1bN0" => '°',
// 176 in CP1252
"\x1bN1" => '±',
// 177 in CP1252
"\x1bN2" => '²',
// 178 in CP1252
"\x1bN3" => '³',
// 179 in CP1252
"\x1bNB " => '´',
// 180 in CP1252
"\x1bN5" => 'µ',
// 181 in CP1252
"\x1bN6" => '¶',
// 182 in CP1252
"\x1bN7" => '·',
// 183 in CP1252
"\x1b+8" => '¸',
// 184 in CP1252
"\x1bNQ" => '¹',
// 185 in CP1252
"\x1bNk" => 'º',
// 186 in CP1252
"\x1bN;" => '»',
// 187 in CP1252
"\x1bN<" => '¼',
// 188 in CP1252
"\x1bN=" => '½',
// 189 in CP1252
"\x1bN>" => '¾',
// 190 in CP1252
"\x1bN?" => '¿',
// 191 in CP1252
"\x1bNAA" => 'À',
// 192 in CP1252
"\x1bNBA" => 'Á',
// 193 in CP1252
"\x1bNCA" => 'Â',
// 194 in CP1252
"\x1bNDA" => 'Ã',
// 195 in CP1252
"\x1bNHA" => 'Ä',
// 196 in CP1252
"\x1bNJA" => 'Å',
// 197 in CP1252
"\x1bNa" => 'Æ',
// 198 in CP1252
"\x1bNKC" => 'Ç',
// 199 in CP1252
"\x1bNAE" => 'È',
// 200 in CP1252
"\x1bNBE" => 'É',
// 201 in CP1252
"\x1bNCE" => 'Ê',
// 202 in CP1252
"\x1bNHE" => 'Ë',
// 203 in CP1252
"\x1bNAI" => 'Ì',
// 204 in CP1252
"\x1bNBI" => 'Í',
// 205 in CP1252
"\x1bNCI" => 'Î',
// 206 in CP1252
"\x1bNHI" => 'Ï',
// 207 in CP1252
"\x1bNb" => 'Ð',
// 208 in CP1252
"\x1bNDN" => 'Ñ',
// 209 in CP1252
"\x1bNAO" => 'Ò',
// 210 in CP1252
"\x1bNBO" => 'Ó',
// 211 in CP1252
"\x1bNCO" => 'Ô',
// 212 in CP1252
"\x1bNDO" => 'Õ',
// 213 in CP1252
"\x1bNHO" => 'Ö',
// 214 in CP1252
"\x1b-7" => '×',
// 215 in CP1252
"\x1bNi" => 'Ø',
// 216 in CP1252
"\x1bNAU" => 'Ù',
// 217 in CP1252
"\x1bNBU" => 'Ú',
// 218 in CP1252
"\x1bNCU" => 'Û',
// 219 in CP1252
"\x1bNHU" => 'Ü',
// 220 in CP1252
"\x1b-=" => 'Ý',
// 221 in CP1252
"\x1bNl" => 'Þ',
// 222 in CP1252
"\x1bN{" => 'ß',
// 223 in CP1252
"\x1bNAa" => 'à',
// 224 in CP1252
"\x1bNBa" => 'á',
// 225 in CP1252
"\x1bNCa" => 'â',
// 226 in CP1252
"\x1bNDa" => 'ã',
// 227 in CP1252
"\x1bNHa" => 'ä',
// 228 in CP1252
"\x1bNJa" => 'å',
// 229 in CP1252
"\x1bNq" => 'æ',
// 230 in CP1252
"\x1bNKc" => 'ç',
// 231 in CP1252
"\x1bNAe" => 'è',
// 232 in CP1252
"\x1bNBe" => 'é',
// 233 in CP1252
"\x1bNCe" => 'ê',
// 234 in CP1252
"\x1bNHe" => 'ë',
// 235 in CP1252
"\x1bNAi" => 'ì',
// 236 in CP1252
"\x1bNBi" => 'í',
// 237 in CP1252
"\x1bNCi" => 'î',
// 238 in CP1252
"\x1bNHi" => 'ï',
// 239 in CP1252
"\x1bNs" => 'ð',
// 240 in CP1252
"\x1bNDn" => 'ñ',
// 241 in CP1252
"\x1bNAo" => 'ò',
// 242 in CP1252
"\x1bNBo" => 'ó',
// 243 in CP1252
"\x1bNCo" => 'ô',
// 244 in CP1252
"\x1bNDo" => 'õ',
// 245 in CP1252
"\x1bNHo" => 'ö',
// 246 in CP1252
"\x1b/7" => '÷',
// 247 in CP1252
"\x1bNy" => 'ø',
// 248 in CP1252
"\x1bNAu" => 'ù',
// 249 in CP1252
"\x1bNBu" => 'ú',
// 250 in CP1252
"\x1bNCu" => 'û',
// 251 in CP1252
"\x1bNHu" => 'ü',
// 252 in CP1252
"\x1b/=" => 'ý',
// 253 in CP1252
"\x1bN|" => 'þ',
// 254 in CP1252
"\x1bNHy" => 'ÿ',
]
Properties
$currencyCode
Currency code.
private
static string|null
$currencyCode
= null
$decimalSeparator
Decimal separator.
private
static string|null
$decimalSeparator
= null
$iconvOptions
iconv options.
private
static string
$iconvOptions
= '//IGNORE//TRANSLIT'
$isIconvEnabled
Is iconv extension avalable?
private
static bool|null
$isIconvEnabled
= null
$thousandsSeparator
Thousands separator.
private
static string|null
$thousandsSeparator
= null
Methods
controlCharacterOOXML2PHP()
Convert from OpenXML escaped control character to PHP control character.
public
static controlCharacterOOXML2PHP(string $textValue) : string
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 (
Parameters
- $textValue : string
-
Value to unescape
Return values
stringcontrolCharacterPHP2OOXML()
Convert from PHP control character to OpenXML escaped control character.
public
static controlCharacterPHP2OOXML(string $textValue) : string
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 (
Parameters
- $textValue : string
-
Value to escape
Return values
stringconvertEncoding()
Convert string from one encoding to another.
public
static convertEncoding(string $textValue, string $to, string $from) : string
Parameters
- $textValue : string
- $to : string
-
Encoding to convert to, e.g. 'UTF-8'
- $from : string
-
Encoding to convert from, e.g. 'UTF-16LE'
Return values
stringconvertPostToString()
Assist with POST items when samples are run in browser.
public
static convertPostToString(string $index[, string $default = '' ]) : string
Never run as part of unit tests, which are command line.
Parameters
- $index : string
- $default : string = ''
Tags
Return values
stringconvertToString()
public
static convertToString(mixed $value[, bool $throw = true ][, string $default = '' ][, bool $convertBool = false ]) : string
Parameters
- $value : mixed
- $throw : bool = true
- $default : string = ''
- $convertBool : bool = false
-
If true, convert bool to locale-aware TRUE/FALSE rather than 1/null-string
Return values
stringcountCharacters()
Get character count.
public
static countCharacters(string $textValue[, string $encoding = 'UTF-8' ]) : int
Parameters
- $textValue : string
- $encoding : string = 'UTF-8'
-
Encoding
Return values
int —Character count
countCharactersDbcs()
Get character count using mb_strwidth rather than mb_strlen.
public
static countCharactersDbcs(string $textValue[, string $encoding = 'UTF-8' ]) : int
Parameters
- $textValue : string
- $encoding : string = 'UTF-8'
-
Encoding
Return values
int —Character count
formatNumber()
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.
public
static formatNumber(float|int|string|null $numericValue) : string
Parameters
- $numericValue : float|int|string|null
Return values
stringgetCurrencyCode()
Get the currency code. If it has not yet been set explicitly, try to obtain the symbol information from locale.
public
static getCurrencyCode([bool $trimAlt = false ]) : string
Parameters
- $trimAlt : bool = false
Return values
stringgetDecimalSeparator()
Get the decimal separator. If it has not yet been set explicitly, try to obtain number formatting information from locale.
public
static getDecimalSeparator() : string
Return values
stringgetIsIconvEnabled()
Get whether iconv extension is available.
public
static getIsIconvEnabled() : bool
Return values
boolgetThousandsSeparator()
Get the thousands separator. If it has not yet been set explicitly, try to obtain number formatting information from locale.
public
static getThousandsSeparator() : string
Return values
stringisUTF8()
Check if a string contains UTF8 data.
public
static isUTF8(string $textValue) : bool
Parameters
- $textValue : string
Return values
boolmbIsUpper()
public
static mbIsUpper(string $character) : bool
Parameters
- $character : string
Return values
boolmbStrSplit()
Splits a UTF-8 string into an array of individual characters.
public
static mbStrSplit(string $string) : array<string|int, string>
Parameters
- $string : string
Return values
array<string|int, string>sanitizeUTF8()
Try to sanitize UTF8, replacing invalid sequences with Unicode substitution characters.
public
static sanitizeUTF8(string $textValue) : string
Parameters
- $textValue : string
Return values
stringsetCurrencyCode()
Set the currency code. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.
public
static setCurrencyCode(string|null $currencyCode) : void
Parameters
- $currencyCode : string|null
-
Character for currency code
setDecimalSeparator()
Set the decimal separator. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.
public
static setDecimalSeparator(string|null $separator) : void
Parameters
- $separator : string|null
-
Character for decimal separator
setThousandsSeparator()
Set the thousands separator. Only used by NumberFormat::toFormattedString() to format output by \PhpOffice\PhpSpreadsheet\Writer\Html and \PhpOffice\PhpSpreadsheet\Writer\Pdf.
public
static setThousandsSeparator(string|null $separator) : void
Parameters
- $separator : string|null
-
Character for thousands separator
strCaseReverse()
Reverse the case of a string, so that all uppercase characters become lowercase and all lowercase characters become uppercase.
public
static strCaseReverse(string $textValue) : string
Parameters
- $textValue : string
-
UTF-8 encoded string
Return values
stringstrlenAllowNull()
public
static strlenAllowNull(string|null $string) : int
Parameters
- $string : string|null
Return values
intstrToLower()
Convert a UTF-8 encoded string to lower case.
public
static strToLower(string $textValue) : string
Parameters
- $textValue : string
-
UTF-8 encoded string
Return values
stringstrToTitle()
Convert a UTF-8 encoded string to title/proper case (uppercase every first character in each word, lower case all other characters).
public
static strToTitle(string $textValue) : string
Parameters
- $textValue : string
-
UTF-8 encoded string
Return values
stringstrToUpper()
Convert a UTF-8 encoded string to upper case.
public
static strToUpper(string $textValue) : string
Parameters
- $textValue : string
-
UTF-8 encoded string
Return values
stringsubstring()
Get a substring of a UTF-8 encoded string.
public
static substring(string $textValue, int $offset[, int|null $length = 0 ]) : string
Parameters
- $textValue : string
-
UTF-8 encoded string
- $offset : int
-
Start offset
- $length : int|null = 0
-
Maximum number of characters in substring
Return values
stringSYLKtoUTF8()
Convert SYLK encoded string to UTF-8.
public
static SYLKtoUTF8(string $textValue) : string
Parameters
- $textValue : string
-
SYLK encoded string
Return values
string —UTF-8 encoded string
testStringAsNumeric()
Retrieve any leading numeric part of a string, or return the full string if no leading numeric (handles basic integer or float, but not exponent or non decimal).
public
static testStringAsNumeric(string $textValue) : float|string
Parameters
- $textValue : string
Return values
float|string —string or only the leading numeric part of the string
UTF8toBIFF8UnicodeLong()
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.
public
static UTF8toBIFF8UnicodeLong(string $textValue) : string
Parameters
- $textValue : string
-
UTF-8 encoded string
Return values
stringUTF8toBIFF8UnicodeShort()
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.
public
static UTF8toBIFF8UnicodeShort(string $textValue[, array<int, array{strlen: int, fontidx: int}> $arrcRuns = [] ]) : string
Parameters
- $textValue : string
-
UTF-8 encoded string
- $arrcRuns : array<int, array{strlen: int, fontidx: int}> = []
-
Details of rich text runs in $value
Return values
stringgetLocaleValue()
private
static getLocaleValue(string $key, string $altKey, string $default[, bool $trimAlt = false ]) : string
Parameters
- $key : string
- $altKey : string
- $default : string
- $trimAlt : bool = false
Return values
stringuseAlt()
private
static useAlt(string $altValue, string $default, bool $trimAlt) : string
Parameters
- $altValue : string
- $default : string
- $trimAlt : bool