fix type of code_point; add check code_point is in the valid range