Skip to content

Commit 497d036

Browse files
committed
Make Use of UTF-8 Explicit
Php manual describes it as good practice to do so.
1 parent a1f90b7 commit 497d036

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static function toDecimal($value)
9696
}
9797

9898
$binX = '';
99-
foreach (mb_str_split($value) as $char) {
99+
foreach (mb_str_split($value, 1, 'UTF-8') as $char) {
100100
$binX .= str_pad(base_convert($char, 16, 2), 4, '0', STR_PAD_LEFT);
101101
}
102102
if (strlen($binX) == 40 && $binX[0] == '1') {

src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static function toDecimal($value)
9696
}
9797

9898
$binX = '';
99-
foreach (mb_str_split($value) as $char) {
99+
foreach (mb_str_split($value, 1, 'UTF-8') as $char) {
100100
$binX .= str_pad(decbin((int) $char), 3, '0', STR_PAD_LEFT);
101101
}
102102
if (strlen($binX) == 30 && $binX[0] == '1') {

src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function evaluate(mixed $roman): array|int|string
8181
}
8282

8383
try {
84-
$arabic = self::calculateArabic(mb_str_split($roman));
84+
$arabic = self::calculateArabic(mb_str_split($roman, 1, 'UTF-8'));
8585
} catch (Exception) {
8686
return ExcelError::VALUE(); // Invalid character detected
8787
}

src/PhpSpreadsheet/Reader/Csv/Delimiter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function countPotentialDelimiters(): void
5555

5656
protected function countDelimiterValues(string $line, array $delimiterKeys): void
5757
{
58-
$splitString = mb_str_split($line, 1);
58+
$splitString = mb_str_split($line, 1, 'UTF-8');
5959
$distribution = array_count_values($splitString);
6060
$countLine = array_intersect_key($distribution, $delimiterKeys);
6161

src/PhpSpreadsheet/Reader/Security/XmlScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private function findCharSet(string $xml): string
8787
public function scan($xml): string
8888
{
8989
// Don't rely purely on libxml_disable_entity_loader()
90-
$pattern = '/\0*' . implode('\0*', mb_str_split($this->pattern)) . '\0*/';
90+
$pattern = '/\0*' . implode('\0*', mb_str_split($this->pattern, 1, 'UTF-8')) . '\0*/';
9191

9292
$xml = "$xml";
9393
if (preg_match($pattern, $xml)) {

src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(?string $id = null, string $cfRule = self::CONDITION
3434

3535
private function generateUuid(): string
3636
{
37-
$chars = mb_str_split('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx');
37+
$chars = mb_str_split('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx', 1, 'UTF-8');
3838

3939
foreach ($chars as $i => $char) {
4040
if ($char === 'x') {

src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,6 @@ private static function setLowercaseCallback(array $matches): string
207207

208208
private static function escapeQuotesCallback(array $matches): string
209209
{
210-
return '\\' . implode('\\', mb_str_split($matches[1]));
210+
return '\\' . implode('\\', mb_str_split($matches[1], 1, 'UTF-8'));
211211
}
212212
}

0 commit comments

Comments
 (0)