Index: src/js/string.js |
diff --git a/src/js/string.js b/src/js/string.js |
index 00fee68ac9fc6d02598c212d89f9af54d135b84a..38caab7b125d1adbe25957d474250faa46eb6f59 100644 |
--- a/src/js/string.js |
+++ b/src/js/string.js |
@@ -116,6 +116,30 @@ |
RegExpInitialize(regexp, pattern); |
return regexp[matchSymbol](subject); |
} |
+ |
+ |
+// ECMA-262 v6, section 21.1.3.12 |
+// |
+// For now we do nothing, as proper normalization requires big tables. |
+// If Intl is enabled, then i18n.js will override it and provide the the |
+// proper functionality. |
+function StringNormalize(formArg) { // length == 0 |
+ CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
+ var s = TO_STRING(this); |
+ |
+ var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); |
+ |
+ var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; |
+ var normalizationForm = %ArrayIndexOf(NORMALIZATION_FORMS, form, 0); |
+ if (normalizationForm === -1) { |
+ throw %make_range_error(kNormalizationForm, |
+ %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); |
+ } |
+ |
+ return s; |
+} |
+ |
+%FunctionSetLength(StringNormalize, 0); |
// This has the same size as the RegExpLastMatchInfo array, and can be used |
@@ -716,6 +740,7 @@ |
"lastIndexOf", StringLastIndexOf, |
"localeCompare", StringLocaleCompareJS, |
"match", StringMatchJS, |
+ "normalize", StringNormalize, |
"repeat", StringRepeat, |
"replace", StringReplace, |
"search", StringSearch, |