[ticket/13297] Fix last char detection.

Thanks @s9e for the input and pointing this out.

PHPBB3-13297