Skip to content

Commit a89ab26

Browse files
authored
v1.1.0 (#3)
* Swapped regex pattern for more widely supported version * Added blank space handling
1 parent 1b4db07 commit a89ab26

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/CharacterConverter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ public function findAndReplace(string $string): string
3030

3131
public function locateCharactersInString(string $string): array
3232
{
33-
preg_match_all("/[^\x00-\x7F]/u", $string, $matches);
33+
preg_match_all("/[^ -~]/u", $string, $matches);
3434

3535
$characters = [];
3636
foreach ($matches[0] as $match) {
37-
if (!in_array($match, $characters)) {
37+
if (trim($match) && !in_array($match, $characters)) {
3838
$characters[] = $match;
3939
}
4040
}
@@ -46,7 +46,7 @@ public function convertArrayToRtf(array $strings): array
4646
{
4747
$convertedStrings = [];
4848
foreach ($strings as $string) {
49-
if (!array_key_exists($string, $convertedStrings)) {
49+
if (trim($string) && !array_key_exists($string, $convertedStrings)) {
5050
$convertedStrings[$string] = $this->convertStringToRtf($string);
5151
}
5252
}

0 commit comments

Comments
 (0)