问题
For context, I have a form in my ReactJS app and I submit:
Awp ACq smr`Q pRBu deI bfweI nwm [
My API ends up saving that value in the database as the following value:
Awp ACq smr`Q pRBu deI bfweI nwm [
However, when I go to display this in the my React app, it renders the following:
This is what (I think) it should be:
How can I correctly display this content in React? It feels like I am doing something wrong by the lack of sources I could find:
- React Javascript displaying/decoding unicode characters (2016)
- https://www.jsdiaries.com/how-to-add-unicode-in-react-js/ (2020)
Here are some additional question I want to clarify:
- When I submit strings (with extended ASCII, special characters) is it normal for the special characters to be encoded? For example, why was converting the
`
to`
necessary? - What is the difference between the Unicode and HTML "representation" of that character? Why did the server decide to use
`
instead ofU+0060
? Which one is more preferable to use to serve to more devices?
来源:https://stackoverflow.com/questions/64073935/how-can-i-render-utf-8-characters-in-jsx-without-using-dangerouslysetinnerhtml-i