将十六进制转换为字符串 Perl <>Cocoa

发布于 12-12 19:53 字数 376 浏览 2 评论 0 原文

我需要一些帮助将一些 Perl 代码转换为 Cocoa (iOS) 等效代码。

Perl 脚本将字符串发送到服务器并打印出响应。字符串本身是根据十六进制值生成的。十六进制值是必须发送的控制字符,并且不可“打印”。

我的问题: 1) 如何在 Cocoa 中将十六进制转换为字符串/字符串转换为十六进制?

在 Perl 中我可以使用这样的东西:

sub sth
{   
my $sendstring = "";
my @hexvalues = @_;

foreach my $hv (@hexvalues)
{
    $string .= sprintf('%c',hex($hv));
}
return $sendstring;
}

I need some help to transform some Perl code to a Cocoa (iOS) equivalent.

The Perl Script sends a string to a server and prints out the response. The string itself is generated from hex values. The hex values are control characters which have to be sent and are not "printable".

My question:
1) How do I convert Hex to String / String to Hex in Cocoa?

In perl I could use something like this:

sub sth
{   
my $sendstring = "";
my @hexvalues = @_;

foreach my $hv (@hexvalues)
{
    $string .= sprintf('%c',hex($hv));
}
return $sendstring;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文