Browse Source

Removing usage of char.IsWhiteSpace

This method has changed with .NET 4.6 and removed
0x180E from the WS list, but JavaScript is expecting it to be one.
The .NET implementation is following Unicode changes.

Fixes #214
Sebastien Ros 9 years ago
parent
commit
51d9256f1c
2 changed files with 4 additions and 12 deletions
  1. 3 11
      Jint/Native/String/StringPrototype.cs
  2. 1 1
      Jint/Parser/JavascriptParser.cs

+ 3 - 11
Jint/Native/String/StringPrototype.cs

@@ -9,6 +9,7 @@ using Jint.Native.RegExp;
 using Jint.Runtime;
 using Jint.Runtime.Descriptors;
 using Jint.Runtime.Interop;
+using Jint.Parser;
 
 namespace Jint.Native.String
 {
@@ -71,15 +72,6 @@ namespace Jint.Native.String
             return s.PrimitiveValue;
         }
 
-        // http://msdn.microsoft.com/en-us/library/system.char.iswhitespace(v=vs.110).aspx
-        // http://en.wikipedia.org/wiki/Byte_order_mark
-        const char BOM_CHAR = '\uFEFF';
-
-        private static bool IsWhiteSpaceEx(char c)
-        {
-            return char.IsWhiteSpace(c) || c == BOM_CHAR;
-        }
-
         private static string TrimEndEx(string s)
         {
             if (s.Length == 0)
@@ -88,7 +80,7 @@ namespace Jint.Native.String
             var i = s.Length - 1;
             while (i >= 0)
             {
-                if (IsWhiteSpaceEx(s[i]))
+                if (JavaScriptParser.IsWhiteSpace(s[i]))
                     i--;
                 else
                     break;
@@ -107,7 +99,7 @@ namespace Jint.Native.String
             var i = 0;
             while (i < s.Length)
             {
-                if (IsWhiteSpaceEx(s[i]))
+                if (JavaScriptParser.IsWhiteSpace(s[i]))
                     i++;
                 else
                     break;

+ 1 - 1
Jint/Parser/JavascriptParser.cs

@@ -92,7 +92,7 @@ namespace Jint.Parser
 
         // 7.2 White Space
 
-        private static bool IsWhiteSpace(char ch)
+        public static bool IsWhiteSpace(char ch)
         {
             return (ch == 32) || // space
                    (ch == 9) || // tab