Problems React encounters when using utf-8
P粉644981029
P粉644981029 2023-08-16 18:52:59
0
1
608
<p>I am developing a React based solution using Visual Studio. My React .js files are encoded in UTF-8. </p> <p>I'm using some Danish text and what confuses me is that I have to rewrite ø as &oslash;</p> <p>The reason I'm confused is because the browser displays UTF-8 replacement characters, so I assume it must be using UTF-8 encoding all the time. </p> <p>Am I overlooking something obvious? </p> <p>Here is a code that demonstrates the problem: </p> <pre class="brush:php;toolbar:false;">render() { return ( <div> Sogning. S&oslash;gning. </div> ); }</pre>
P粉644981029
P粉644981029

reply all(1)
P粉755863750

You can use the following ways to represent them in js files:

import utf8 from "utf8";

const encoded = utf8.encode(Søgning)

If you use this in a .jsx file, there is no need to encode special characters. You can use it like this in a .jsx file:

render() {
    return (
        <div>
            Søgning.
            Søgning.
        </div>
    );
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template