From: Tim Düsterhus Date: Sat, 27 Apr 2013 14:44:01 +0000 (+0200) Subject: Use proper UTF-8 MINUS SIGN X-Git-Tag: 2.0.0_Beta_1~288^2^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7e969bc772b79082c03b29420a9ba7d8197c4253;p=GitHub%2FWoltLab%2FWCF.git Use proper UTF-8 MINUS SIGN --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index bb51ceb9de..055999c62f 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -2934,16 +2934,16 @@ WCF.MultipleLanguageInput = Class.extend({ */ WCF.Number = { /** - * Rounds a number to a given number of floating points digits. Defaults to 0. + * Rounds a number to a given number of decimal places. Defaults to 0. * * @param number number - * @param floatingPoint number of digits + * @param decimalPlaces number of decimal places * @return number */ - round: function (number, floatingPoint) { - floatingPoint = Math.pow(10, (floatingPoint || 0)); + round: function (number, decimalPlaces) { + decimalPlaces = Math.pow(10, (decimalPlaces || 0)); - return Math.round(number * floatingPoint) / floatingPoint; + return Math.round(number * decimalPlaces) / decimalPlaces; } }; @@ -2988,11 +2988,14 @@ WCF.String = { * @param mixed number * @return string */ - formatNumeric: function(number, floatingPoint) { - number = String(WCF.Number.round(number, floatingPoint || 2)); + formatNumeric: function(number, decimalPlaces) { + number = String(WCF.Number.round(number, decimalPlaces || 2)); number = number.replace('.', WCF.Language.get('wcf.global.decimalPoint')); - return this.addThousandsSeparator(number); + number = this.addThousandsSeparator(number); + number = number.replace('-', '\u2212'); + + return number; }, /** diff --git a/wcfsetup/install/files/lib/util/StringUtil.class.php b/wcfsetup/install/files/lib/util/StringUtil.class.php index 6e483cc856..d042630a9d 100644 --- a/wcfsetup/install/files/lib/util/StringUtil.class.php +++ b/wcfsetup/install/files/lib/util/StringUtil.class.php @@ -21,11 +21,17 @@ final class StringUtil { const HTML_COMMENT_PATTERN = '~~'; /** - * utf8 bytes of the horizontal ellipsis char + * utf8 bytes of the HORIZONTAL ELLIPSIS (U+2026) * @var string */ const HELLIP = "\xE2\x80\xA6"; + /** + * utf8 bytes of the MINUS SIGN (U+2212) + * @var string + */ + const MINUS = "\xE2\x88\x92"; + /** * Alias to php sha1() function. * @@ -141,17 +147,19 @@ final class StringUtil { * @return string */ public static function formatNumeric($numeric) { - if (is_int($numeric)) + if (is_int($numeric)) { return self::formatInteger($numeric); - - else if (is_float($numeric)) + } + else if (is_float($numeric)) { return self::formatDouble($numeric); - + } else { - if (floatval($numeric) - (float) intval($numeric)) + if (floatval($numeric) - (float) intval($numeric)) { return self::formatDouble($numeric); - else + } + else { return self::formatInteger(intval($numeric)); + } } } @@ -164,6 +172,9 @@ final class StringUtil { public static function formatInteger($integer) { $integer = self::addThousandsSeparator($integer); + // format minus + $integer = self::formatNegative($integer); + return $integer; } @@ -192,6 +203,9 @@ final class StringUtil { // add thousands separator $double = self::addThousandsSeparator($double); + // format minus + $double = self::formatNegative($double); + return $double; } @@ -209,6 +223,16 @@ final class StringUtil { return $number; } + /** + * Replaces the MINUS-HYPHEN with the MINUS SIGN + * + * @param mixed $number + * @return string + */ + public static function formatNegative($number) { + return self::replace('-', self::MINUS, $number); + } + /** * Sorts an array of strings and maintain index association. *