在Delphi 7中相当于Unicode的chr [英] chr equivalent for Unicode in Delphi 7

查看:268
本文介绍了在Delphi 7中相当于Unicode的chr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Delphi 7中初始化一个Widestring,但是我不能使用 chr 是ANSI的函数

I need to initialize a Widestring in Delphi 7 but I can't use chr function which is ANSI

var
  ws : Widestring;
begin

 ws := chr($FFFF) + chr($FFFF) + chr($FFFF);

end;

我可以使用什么,然后呢?

What can I use, then ?

谢谢

推荐答案

我不确定是否有一种简单的方法可以完成您想要的事情。您可以通过简单的转换将 Word 转换为 WideChar

I'm not sure there's a simply way to do what you wish. You can convert a Word into a WideChar with a simple cast:

WideChar($FFFF)

但是您不能连接 WideChar 。因此,这是一个编译器错误:

but you cannot concatenate WideChar. So this is a compiler error:

WideChar($FFFF) + WideChar($FFFF)

您可以使用助手功能来完成工作:

You could use a helper function to get the job done:

function InitialiseWideString(const chars: array of Word): WideString;
var
  i: Integer;
begin
  SetLength(Result, Length(chars));
  for i := 0 to high(chars) do
    Result[i+1] := WideChar(chars[i]);
end;

然后您可以这样称呼它:

Then you can call it like this:

ws := InitialiseWideString([$0054, $0069, $006D, $0065, $0020, $0074, $006F, 
  $0020, $0075, $0070, $0067, $0072, $0061, $0064, $0065]);

这篇关于在Delphi 7中相当于Unicode的chr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆