How to deal with web users entering special characters?

I now have such a problem, which requires that the user can enter special characters, but it needs to be displayed after typing, and the input segment can also be edited, and the display is still corresponding to which characters are entered instead of coding. The background has been processed to convert entity characters, do I have to convert these entity characters back to

every time?
Mar.04,2021

well, I think it depends on what the product says. Generally speaking, some special characters can be displayed in order to take into account the user experience (for example, some special characters are used in emoticons), but some shielded words may have to be removed. For example, I have seen a better way to deal with the experience is to replace it with "meow" (instant App). Of course, if the backend memory is stored, it must still be converted to


.
  • masking words must be done in the background, and you can't store the associated table of masking words at the front end. But it is easier to deal with special characters.
  • you can transcode these special characters into secure characters at the front end and then submit them.
 encodeURIComponent ('(o)')   //(o%E2%97%95%E2%88%80%E2%97%95)%EF%BE%89
  • you can switch back to
when you use these characters at the front end.
decodeURIComponent((o%E2%97%95%E2%88%80%E2%97%95)%EF%BE%89)   //(o)
  • if you find the front end troublesome, you can give it to the backend to do it, in the same way.
Menu