trim() does not remove "all whitespace characters" from the ends of your string, but only a limited number of fixed characters:
" " (ASCII 32 (0x20)), an ordinary space.
"\t" (ASCII 9 (0x09)), a tab.
"\n" (ASCII 10 (0x0A)), a new line (line feed).
"\r" (ASCII 13 (0x0D)), a carriage return.
"\0" (ASCII 0 (0x00)), the NUL-byte.
"\x0B" (ASCII 11 (0x0B)), a vertical tab.
https://www.php.net/manual/en/function.trim.php
Your characters might be rendered as whitespace. However, they are not included in this list and are, hence, not removed.
You can pass a second parameter to trim() to specify the list of characters you want to have removed:
character_mask
Optionally, the stripped characters can also be specified using the character_mask parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters.
https://www.php.net/manual/en/function.trim.php