aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--String.php15
-rw-r--r--Test/Unit/String.php5
2 files changed, 17 insertions, 3 deletions
diff --git a/String.php b/String.php
index bbcb1dd..1c5e47d 100644
--- a/String.php
+++ b/String.php
@@ -478,9 +478,20 @@ class String implements \ArrayAccess, \Countable, \IteratorAggregate {
$string = $this->_string;
- if(null !== $transliterator = static::getTransliterator('Any-Latin; Latin-ASCII')) {
+ $transId = 'Any-Latin; ' .
+ '[\p{S}] Name; ' .
+ 'Latin-ASCII';
- $this->_string = $transliterator->transliterate($string);
+ if(null !== $transliterator = static::getTransliterator($transId)) {
+
+ $this->_string = preg_replace_callback(
+ '#\\\N\{([A-Z ]+)\}#u',
+ function ( Array $matches ) {
+
+ return '(' . strtolower($matches[1]) . ')';
+ },
+ $transliterator->transliterate($string)
+ );
return $this;
}
diff --git a/Test/Unit/String.php b/Test/Unit/String.php
index 82710ef..b61c351 100644
--- a/Test/Unit/String.php
+++ b/Test/Unit/String.php
@@ -934,7 +934,10 @@ class String extends Test\Unit\Suite {
=> 'monica',
'क्ष'
- => 'ksa'
+ => 'ksa',
+
+ 'أحبك 😀'
+ => 'ahbk (grinning face)'
]
)
->when(function ( ) use ( $strings ) {