【发布时间】:2020-08-12 22:23:59
【问题描述】:
我已经像这样从 cli 和 php 脚本调用:
# php test.php
php脚本内容:
<?php
echo chr(201);
这是 CLI 左上角的方角
但它显示É 字符和预期:
(对不起,我没有为帖子找到这个角色)。
我已经尝试使用其他方法让它工作,但没有任何工作:
<?php
echo mb_convert_encoding(chr(201), 'UTF-8', 'ISO-8859-1');
<?php
echo utf8_encode(chr(201));
PHP 文件是 UTF-8,没有 BOM。
终端设置:
更新:文本输出:
<0x1b[1;0m
array [
'idprocess' => string(11): 'c-cron-0001',
'idform' => string(11): 'c-cron-0001',
]
<0x1b>[0m
<0x1b>[1;0m
array [
'idprocess' => string(11): 'c-cron-0004',
'idform' => string(11): 'c-cron-0004',
]
<0x1b>[0m
<0x1b>[1;0m
array [
'idprocess' => string(11): 'c-cron-0005',
'idform' => string(11): 'c-cron-0005',
]
<0x1b>[0m
<0x1b>[1;0m
array [
'idprocess' => string(11): 'c-cron-0006',
'idform' => string(11): 'c-cron-0006',
]
<0x1b>[0m
<0x1b>[1;0m
array [
'idprocess' => string(11): 'c-cron-0007',
'idform' => string(11): 'c-cron-0007',
]
<0x1b>[0m
更新:drawbox 函数的输出:
╔══════════════════════════════════════════════════════════════════════════════╗
║ <0x1b>[1;0m ║
║ array [ ║
║ 'idprocess' => string(11): 'c-cron-0001', ║
║ 'idform' => string(11): 'c-cron-0001', ║
║ ] ║
║ <0x1b>[0m ║
║ <0x1b>[1;0m ║
║ array [ ║
║ 'idprocess' => string(11): 'c-cron-0004', ║
║ 'idform' => string(11): 'c-cron-0004', ║
║ ] ║
║ [0m ║
║ [1;0m ║
║ array [ ║
║ 'idprocess' => string(11): 'c-cron-0005', ║
║ 'idform' => string(11): 'c-cron-0005', ║
║ ] ║
║ <0x1b>[0m ║
║ <0x1b>[1;0m ║
║ array [ ║
║ 'idprocess' => string(11): 'c-cron-0006', ║
║ 'idform' => string(11): 'c-cron-0006', ║
║ ] ║
║ <0x1b>[0m ║
║ <0x1b>[1;0m ║
║ array [ ║
║ 'idprocess' => string(11): 'c-cron-0007', ║
║ 'idform' => string(11): 'c-cron-0007', ║
║ ] ║
║ <0x1b>[0m ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝
【问题讨论】:
-
为什么会这样?您是否使用正确的编码保存文件?您的终端是否理解扩展字符?它甚至使用支持它们的字体吗?另外,在这里显示“随机图片”也无济于事,请向您的终端显示它甚至可以显示您正在输出的字符,否则问题几乎可以肯定是您的终端设置,可能不是 php。
-
@biesior 我上传了图片,因为 php 手册中有参考资料,而且图片我无法从图片中复制字符:
-
@biesior php.net/manual/es/function.chr.php
-
@biesior asciitable.com 你能看到代码 201 吗? ascci 表的我输出了什么,但我得到了这个 stange 字符输出i.stack.imgur.com/XbcoK.png
-
@biesior,我无法复制奇怪的字符......因为你要我编辑我的问题并添加一个不是网络的输出,所以我无法以文本形式获得结果;一切都从 CLI 运行???