Commit 39356457 authored by Pierre Ynard's avatar Pierre Ynard

lua http: use us_tostring() to fix locale issues with decimals

The function is a bit ugly but it's difficult to do this using
pure arithmetic.

Fixes #6378
(cherry picked from commit 1e9dc296)
Signed-off-by: default avatarPierre Ynard <linkfanel@yahoo.fr>
parent 45618999
...@@ -68,6 +68,13 @@ function us_tonumber(str) ...@@ -68,6 +68,13 @@ function us_tonumber(str)
return s * (tonumber(i) + tonumber(d)/(10^string.len(d))) return s * (tonumber(i) + tonumber(d)/(10^string.len(d)))
end end
-- tostring() for decimals number, using a dot as decimal separator
-- regardless of the system locale
function us_tostring(n)
s = tostring(n):gsub(",", ".", 1)
return s
end
-- strip leading and trailing spaces -- strip leading and trailing spaces
function strip(str) function strip(str)
return string.gsub(str, "^%s*(.-)%s*$", "%1") return string.gsub(str, "^%s*(.-)%s*$", "%1")
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
module("httprequests",package.seeall) module("httprequests",package.seeall)
local common = require ("common")
local dkjson = require ("dkjson") local dkjson = require ("dkjson")
...@@ -201,6 +202,8 @@ end ...@@ -201,6 +202,8 @@ end
function xmlString(s) function xmlString(s)
if (type(s)=="string") then if (type(s)=="string") then
return vlc.strings.convert_xml_special_chars(s) return vlc.strings.convert_xml_special_chars(s)
elseif (type(s)=="number") then
return common.us_tostring(s)
else else
return tostring(s) return tostring(s)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment