Browse Source

Applied to LuaValue.cs and BasicLibrary.cs

Flouttre 1 year ago
parent
commit
6c16970396
2 changed files with 4 additions and 2 deletions
  1. 2 1
      src/Lua/LuaValue.cs
  2. 2 1
      src/Lua/Standard/BasicLibrary.cs

+ 2 - 1
src/Lua/LuaValue.cs

@@ -1,3 +1,4 @@
+using System.Globalization;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using Lua.Internal;
@@ -120,7 +121,7 @@ public readonly struct LuaValue : IEquatable<LuaValue>
                     }
                     else
                     {
-                        var tryResult = double.TryParse(str, out var d);
+                        var tryResult = double.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out var d);
                         result = tryResult ? Unsafe.As<double, T>(ref d) : default!;
                         return tryResult;
                     }

+ 2 - 1
src/Lua/Standard/BasicLibrary.cs

@@ -1,3 +1,4 @@
+using System.Globalization;
 using Lua.CodeAnalysis.Compilation;
 using Lua.Internal;
 using Lua.Runtime;
@@ -445,7 +446,7 @@ public sealed class BasicLibrary
             }
             else if (toBase == 10)
             {
-                if (double.TryParse(str, out var result))
+                if (double.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
                 {
                     value = result;
                 }