Index: src/string.js |
diff --git a/src/string.js b/src/string.js |
index 14b44ca41f3d7f248a5756b54983f09ab3a55c8e..809d24f033fdc70b0547fe47c0ed887fa855c3ff 100644 |
--- a/src/string.js |
+++ b/src/string.js |
@@ -200,6 +200,31 @@ function StringMatch(regexp) { |
} |
+var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; |
+ |
+ |
+// 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(form) { |
+ if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
mathias
2014/01/29 09:05:55
While this is correct, it might be better to just
|
+ throw MakeTypeError("called_on_null_or_undefined", |
+ ["String.prototype.localeCompare"]); |
mathias
2014/01/29 09:05:55
s/localeCompare/normalize/
|
+ } |
+ |
+ var form = form ? TO_STRING_INLINE(form) : 'NFC'; |
+ var normalizationForm = NORMALIZATION_FORMS.indexOf(form); |
+ if (normalizationForm === -1) { |
+ throw new $RangeError('The normalization form should be one of ' |
+ + NORMALIZATION_FORMS.join(', ') + '.'); |
+ } |
+ |
+ return %_ValueOf(this); |
+} |
+ |
+ |
// This has the same size as the lastMatchInfo array, and can be used for |
// functions that expect that structure to be returned. It is used when the |
// needle is a string rather than a regexp. In this case we can't update |
@@ -984,6 +1009,7 @@ function SetUpString() { |
"lastIndexOf", StringLastIndexOf, |
"localeCompare", StringLocaleCompare, |
"match", StringMatch, |
+ "normalize", StringNormalize, |
"replace", StringReplace, |
"search", StringSearch, |
"slice", StringSlice, |