[BUGFIX] Use mbstring for capitalizing a string 95/49795/2
authorPhilipp Gampe <philipp.gampe@typo3.org>
Thu, 1 Sep 2016 15:07:17 +0000 (17:07 +0200)
committerPhilipp Gampe <philipp.gampe@typo3.org>
Fri, 2 Sep 2016 23:37:57 +0000 (01:37 +0200)
If mbstring is available, use mb_convert_case instead of ucwords.

Resolves: #52244
Releases: master, 7.6
Change-Id: Ia6840fdda96d5511444afa014ebbcb01cbbf3ed0
Reviewed-on: https://review.typo3.org/49795
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Philipp Gampe <philipp.gampe@typo3.org>
Tested-by: Philipp Gampe <philipp.gampe@typo3.org>
typo3/sysext/core/Classes/Charset/CharsetConverter.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index edef648..4b1533e 100644 (file)
@@ -1662,6 +1662,22 @@ class CharsetConverter
     }
 
     /**
+     * Capitalize the given string
+     *
+     * @param string $charset
+     * @param string $string
+     * @return string
+     */
+    public function convCapitalize($charset, $string)
+    {
+        if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] === 'mbstring') {
+            return mb_convert_case($string, MB_CASE_TITLE, $charset);
+        } else {
+            return ucwords($string);
+        }
+    }
+
+    /**
      * Converts special chars (like æøåÆØÅ, umlauts etc) to ascii equivalents (usually double-bytes, like æ => ae etc.)
      *
      * @param string $charset Character set of string
index 6d965fa..9365202 100644 (file)
@@ -7383,7 +7383,7 @@ class ContentObjectRenderer
                 $theValue = $tsfe->csConvObj->conv_case($tsfe->renderCharset, $theValue, 'toLower');
                 break;
             case 'capitalize':
-                $theValue = ucwords($theValue);
+                $theValue = $tsfe->csConvObj->convCapitalize($tsfe->renderCharset, $theValue);
                 break;
             case 'ucfirst':
                 $theValue = $tsfe->csConvObj->convCaseFirst($tsfe->renderCharset, $theValue, 'toUpper');