小编Mar*_*man的帖子

Lua string.match模式为MSN weatherservice

我使用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"

我认为角色/是问题所在.

string lua lua-patterns

4
推荐指数
1
解决办法
84
查看次数

在纯 LUA 中将 UTF-8 字符串转换为 ASCII

我有一个关于发送和接收带有特殊字符的数据的问题。(德语元音变音)

\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)

lua ascii utf-8

1
推荐指数
1
解决办法
1万
查看次数

我如何使用 LuaSec 在 HTTPS 中发送

在我的脚本中,我使用库 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 的工作代码?

https lua luasocket luasec

0
推荐指数
1
解决办法
3173
查看次数

标签 统计

lua ×3

ascii ×1

https ×1

lua-patterns ×1

luasec ×1

luasocket ×1

string ×1

utf-8 ×1