Last few months, I have started working on a web application that belongs to a Swedish client. Since this application's target audience is Swedish people, we were only focused on the Swedish language as the application language. We have hardcoded all the labels (I know it is not a good practice but for this case that was fine 😉). Then we figured out something is wrong when it rendered in the HTML.
Usage:
In your browser, go to the developer toolbar and in the network tab, when you check the response headers. You can see in the content-type, it indicates your "charset" property value as follow,
However, this did not resolve my issue. So I dig into this and figure out something else. You might have the same issue as me. So it is not about the character encoding this time. even though we set the character encoding to "charset" as "UTF-8". The file (in my case react component file) encoding is different. So even I set the character encoding to "UTF-8", file encoding is overridden it.
So in order to check the file encoding, you need to get the support of Visual Studio editor (Not VS Code).
This may be a stupid post for some but this ruined one working day of mine.
May the force be with you!
Symptoms
All the special Swedish characters were rendered as �
åäö Swedish characters shown as �
Cause
This is most likely caused by the encoding.
Resolution
Ideally, you can overcome this issue by providing a metadata tag for "charset".
In your index.html file, add the following meta tag to the header section.
Simply, when you declare the "charset" as "UTF-8", you are telling your browser to use the UTF-8 character encoding, which is a method of converting your typed characters into machine-readable code.In your index.html file, add the following meta tag to the header section.
<meta charset="UTF-8">
Usage:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>My Website</title>
</head>
<body>
</body>
</html>
Read more: what is it | how to useIn your browser, go to the developer toolbar and in the network tab, when you check the response headers. You can see in the content-type, it indicates your "charset" property value as follow,
However, this did not resolve my issue. So I dig into this and figure out something else. You might have the same issue as me. So it is not about the character encoding this time. even though we set the character encoding to "charset" as "UTF-8". The file (in my case react component file) encoding is different. So even I set the character encoding to "UTF-8", file encoding is overridden it.
So in order to check the file encoding, you need to get the support of Visual Studio editor (Not VS Code).
- Open Visual Studio.
- Open the desired file to be check.
- From the File menu, choose Save File As, and then click the drop-down button next to the Save button.
- The Advanced Save Options dialog box is displayed.
- Under Encoding, check what is listed in there. It should not be a UTF-8 encode type. So you can select a UTF-8 encoding type and click ok. This will convert your file to UTF-8 encode type and that will resolve your issue.
Step 3
|
May the force be with you!
Comments
Post a Comment