What are the potential pitfalls of using the ord() and chr() functions in PHP?

One potential pitfall of using the ord() and chr() functions in PHP is that they may not handle Unicode characters correctly, leading to unexpected results or errors. To avoid this issue, it is recommended to use the mb_ord() and mb_chr() functions instead, which provide better support for Unicode characters.

function mb_ord($char)
{
    $char = mb_convert_encoding($char, 'UCS-4BE', 'UTF-8');
    $char = unpack('N', $char);
    return $char[1];
}

function mb_chr($ord)
{
    $char = pack('N', $ord);
    $char = mb_convert_encoding($char, 'UTF-8', 'UCS-4BE');
    return $char;
}