please use `mb_strlen` and `mb_substr` here to support multibyte strings.