How to handle user input of invalid UTF-8 characters?

后端 未结 9 2025
小鲜肉
小鲜肉 2020-11-29 17:26

I\'m looking for general a strategy/advice on how to handle invalid UTF-8 input from users.

Even though my webapp uses UTF-8, somehow some users enter invalid chara

9条回答
  •  再見小時候
    2020-11-29 18:26

    Set UTF-8 as the character set for all headers output by your PHP code

    In every PHP output header, specify UTF-8 as the encoding:

    header('Content-Type: text/html; charset=utf-8');
    

提交回复
热议问题