我使用MSN weatherservice.现在我有以下问题string.match.所有变量都被填充,除了sWindRichtung.它等于nil.
sHumidity, rest = string.match(rest,"humidity=\"([^\"]+)\"(.*)");
sWind, rest = string.match(rest,"windspeed=\"([^\"]+)\"(.*)");
sWindRichtung, rest = string.match(rest,"winddisplay=\"([^\"]+)\"(.*)");
Run Code Online (Sandbox Code Playgroud)
要过滤的字符串是: humidity="77" winddisplay="11 km/uur N" windspeed="11"
我认为角色/是问题所在.
我有一个关于发送和接收带有特殊字符的数据的问题。(德语元音变音)
\n\n当我使用下面的代码发送字符串“Caf\xc3\xa9 Zeezicht”时,那么在服务器端该字符串就可以了。
\n\n但是如何接收并解码包含相同字符的接收数据呢?现在看起来像“Café?Zeezicht”
\n\n我正在寻找一个纯LUA函数,因为我没有能力加载库。
\n\n------------------------------------------------------------\n-- Function voor converting ASCII naar UTF8\n------------------------------------------------------------\n\n-- return char as utf8 string\nlocal function CodeToUTF8 (Unicode)\n if (Unicode == nil) then \n return ""\n end\n\n if (Unicode < 0x20) then return \' \'; end;\n\n if (Unicode <= 0x7F) then return string.char(Unicode); end;\n\n if (Unicode <= 0x7FF) then\n local Byte0 = 0xC0 + math.floor(Unicode / 0x40);\n local Byte1 = 0x80 + (Unicode % 0x40);\n return string.char(Byte0, Byte1);\n end;\n\n if (Unicode <= 0xFFFF) then\n …Run Code Online (Sandbox Code Playgroud) 在我的脚本中,我使用库 LuaSocket 发送 XML 代码。这适用于以下代码:
local request_body = (XMLHeader..XMLBody);
local response_body = {}
local res, code, response_headers = socket.http.request
{
url = "http://blabla.com/v01/Authenticatie.svc";
method = "POST";
headers =
{
["Content-Type"] = "application/soap+xml; charset=utf-8";
["Content-Length"] = string.len(request_body);
["Accept-Encoding"] = "gzip, deflate";
["Connection"] = "Keep-Alive";
};
source = ltn12.source.string(request_body);
sink = ltn12.sink.table(response_body);
}
Run Code Online (Sandbox Code Playgroud)
但是现在我将使用带有证书的协议 HTTPS 发送 XML。我知道我可以使用 LuaSec 但如何使用?有人可以告诉我,我如何将代码修改为 HTTPS 的工作代码?