如何从 LCDHype 中的插件 return 空格?
How to return spaces from a plugin in LCDHype?
我已经使用 Delphi 为 LCDHype 编写了一个插件,我想要 return 一个包含空格的字符串。这是一个例子:
...
implementation
...
var
gReturnValue: String;
// Plugin.Foo.GetBar
function Library_GetBar(const AParameter: PScriptFunctionImplementationParameter): PWideChar; stdcall;
begin
gReturnValue := 'This is a bar';
result := PWideChar(gReturnValue);
end;
应用程序以某种方式从字符串中删除了这些空格,并且永远不会显示。
我该如何解决这个问题?
披露:我是 LCDHype 的作者
插件的 return 值由 LCDHype 解析,这意味着 return 值基本上是脚本代码。
这也意味着当您想要保留空格时,您必须 return 一个 字符串 。 字符串以'
字符开始和结束,如
'This is a bar'
在 Delphi 中,您需要转义 '
个字符,因此值为
'''This is a bar'''
您可以使用QuotedStr()
转义'
字符并正确引用字符串,例如:
uses SysUtils; // for QuotedStr()
...
function Library_GetBar(const AParameter: PScriptFunctionImplementationParameter): PWideChar; stdcall;
begin
gReturnValue := QuotedStr('This is a bar');
result := PWideChar(gReturnValue);
end;
我已经使用 Delphi 为 LCDHype 编写了一个插件,我想要 return 一个包含空格的字符串。这是一个例子:
...
implementation
...
var
gReturnValue: String;
// Plugin.Foo.GetBar
function Library_GetBar(const AParameter: PScriptFunctionImplementationParameter): PWideChar; stdcall;
begin
gReturnValue := 'This is a bar';
result := PWideChar(gReturnValue);
end;
应用程序以某种方式从字符串中删除了这些空格,并且永远不会显示。
我该如何解决这个问题?
披露:我是 LCDHype 的作者
插件的 return 值由 LCDHype 解析,这意味着 return 值基本上是脚本代码。
这也意味着当您想要保留空格时,您必须 return 一个 字符串 。 字符串以'
字符开始和结束,如
'This is a bar'
在 Delphi 中,您需要转义 '
个字符,因此值为
'''This is a bar'''
您可以使用QuotedStr()
转义'
字符并正确引用字符串,例如:
uses SysUtils; // for QuotedStr()
...
function Library_GetBar(const AParameter: PScriptFunctionImplementationParameter): PWideChar; stdcall;
begin
gReturnValue := QuotedStr('This is a bar');
result := PWideChar(gReturnValue);
end;