
c#字符串添加chr127
PHP provides the chr()
function in order to convert the given number into a single character or string. Even it is called byte value it is an integer which can be between 0 and 255.
PHP提供了chr()
函数,以便将给定的数字转换为单个字符或字符串。 即使它被称为字节值,它也是一个可以在0到255之间的整数。
将字节转换为字符 (Convert Byte To Char)
In the following example, we will convert the given byte values or integers into a character or string. The syntax is very simple where the byte value is provided as a parameter and the single character or string is returned.
在下面的示例中,我们将给定的字节值或整数转换为字符或字符串。 语法非常简单,其中字节值作为参数提供,并且返回单个字符或字符串。
STRING = chr(BYTE_VALUE);
- STRING is the string or character type variable where the BYTE_VALUE character representation will be assigned. STRING是将分配BYTE_VALUE字符表示形式的字符串或字符类型变量。
- BYTE_VALUE is the value we want to convert to the char or string. BYTE_VALUE是我们要转换为char或字符串的值。
$str = chr(240) . chr(159) . chr(144) . chr(152);
echo $str;
#The output will be 🐘
$str = chr(144);
echo $str;
#The output will be �
$str = chr(89);
echo $str;
# Output will be Y
$str = chr(88);
echo $str;
#The output will be X
$str = chr(87);
echo $str;
#The output will be W

如果该值大于256(If The Value Is Higher Than 256)
In some cases, the value can be higher than the 256 which is the limit of the chr() function. Or the value can be lower than the 0 as a negative number like -56. In this case, the mod operation is implemented were given out of range values will be converted between 0 and 256.
在某些情况下,该值可以大于chr()函数的限制256。 或者该值可以小于0作为负数,例如-56。 在这种情况下,如果在超出范围的情况下执行mod操作,则将在0到256之间转换值。
$str = chr(-169);
echo $str;
#The output will be W
$str = chr(87);
echo $str;
#The output will be W
$str = chr(-170);
echo $str;
#The output will be V
$str = chr(86);
echo $str;
#The output will be V
$str = chr(342);
echo $str;
#The output will be V

ASCII表 (ASCII Table)
chr() function uses the ASCII table for byte value or integer value into a single character or string conversion. ASCII table provides the given single character numeric equation like below. For example, 62 will be converted into the < sign.
chr()函数使用ASCII表将字节值或整数值转换为单个字符或字符串。 ASCII表提供了给定的单字符数字方程,如下所示。 例如,将62转换为<符号。

翻译自: https://www.poftut.com/php-chr-function-to-convert-byte-to-character-string/
c#字符串添加chr127