Skip to content

Commit

Permalink
Fix(DecimalCode): add Arabic Letter Mark to rtl
Browse files Browse the repository at this point in the history
  • Loading branch information
robisim74 committed May 1, 2017
1 parent 0c1d3ca commit 605c2d6
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/models/validation/decimal-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,25 @@ export class DecimalCode extends NumberCode {
let value: number = -0.9; // Reference value.
let localeValue: string = new Intl.NumberFormat(defaultLocale).format(value);

// Checks Unicode character 'RIGHT-TO-LEFT MARK' (U+200F).
if (this.Unicode(localeValue.charAt(0)) == "\\u200F") {
const unicodeChars: string[] = [];
unicodeChars.push(this.Unicode(localeValue.charAt(0)));
unicodeChars.push(this.Unicode(localeValue.charAt(1)));
unicodeChars.push(this.Unicode(localeValue.charAt(2)));
unicodeChars.push(this.Unicode(localeValue.charAt(3)));

// Checks Unicode characters 'RIGHT-TO-LEFT MARK' (U+200F) & 'Arabic Letter Mark (U+061C)'.
if (unicodeChars[0] == "\\u200F" || unicodeChars[0] == "\\u061C") {
// Right to left.
this.minusSignCode = this.Unicode(localeValue.charAt(1));
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(3));
} else if (this.Unicode(localeValue.charAt(0)) == this.Unicode(
new Intl.NumberFormat(defaultLocale).format(0)
)) {
// IE & Edge reverse the order.
this.minusSignCode = this.Unicode(localeValue.charAt(3));
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(1));
this.minusSignCode = unicodeChars[1];
this.decimalSeparatorCode = unicodeChars[3];
} else if (unicodeChars[0] == this.Unicode(new Intl.NumberFormat(defaultLocale).format(0))) {
// Some IE & Edge versions reverse the order.
this.minusSignCode = unicodeChars[3];
this.decimalSeparatorCode = unicodeChars[1];
} else {
// Left to right.
this.minusSignCode = this.Unicode(localeValue.charAt(0));
this.decimalSeparatorCode = this.Unicode(localeValue.charAt(2));
this.minusSignCode = unicodeChars[0];
this.decimalSeparatorCode = unicodeChars[2];
}
}
}
Expand Down

0 comments on commit 605c2d6

Please sign in to comment.