fix a problem when the character string beyond the number of the maximum characters is passed