From bdd0ae59b04485e0a2fe7beaf5eed758a7c4f4d1 Mon Sep 17 00:00:00 2001 From: phamcuong Date: Fri, 1 Oct 2021 11:13:54 +0700 Subject: [PATCH] Fix broken decimal separator replacement when it is more than one byte length (don't assume it's length always 1) --- Helper/Data.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Helper/Data.php b/Helper/Data.php index 3c61bbd..8d6ef29 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -363,8 +363,9 @@ public function getDirectoryCurrency($result, $decimal, $original, $config) return str_replace($original['groupSymbol'], $config['group_separator'], $processedCurrency); } - $decimalPart = substr($result, -($decimal + 1), $decimal + 1); - $currencyPart = substr($result, 0, strlen($result) - ($decimal + 1)); + $decimalSeparatorLength = strlen($original['decimalSymbol']); + $decimalPart = substr($result, -($decimal + $decimalSeparatorLength), $decimal + $decimalSeparatorLength); + $currencyPart = substr($result, 0, strlen($result) - ($decimal + $decimalSeparatorLength)); $currencyPartResult = str_replace($original['groupSymbol'], $config['group_separator'], $currencyPart); $decimalPartResult = str_replace($original['decimalSymbol'], $config['decimal_separator'], $decimalPart); $result = $currencyPartResult . $decimalPartResult;