Reputation: 53
I am trying to fetch the swedish content from another site. I am able to fetch the data but the Swedish characters(ÅÖÄ) are missing. Swedish Content that I have added directly has no issue to display as i have added the meta-tag. The issue is when i am trying to display the data from another site. Is it possible to fix this issue. I do not have any access to other site.
Upvotes: 0
Views: 2141
Reputation: 1390
To take into account Swedish characters, you need to set the charset
to UTF-8
. An example from MDN is:
<!-- In HTML5 -->
<meta charset="utf-8">
<!-- Defining the charset in HTML4 -->
<!-- Note: This is invalid in HTML5 -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
The meta tag goes in the <head>
tag like so:
<html>
<head>
<meta charset="UTF-8">
</head>
</html>
To quote from MDN:
[charset] declares the character encoding used of the page. It can be locally overridden using the lang attribute on any element. This attribute is a literal string and must be one of the preferred MIME names for a character encoding as defined by the IANA. Though the standard doesn't request a specific character encoding, it gives some recommendations:
- Authors are encouraged to use UTF-8.
- Authors should not use ASCII-incompatible encodings (i.e. those that don't map the 8-bit code points 0x20 to 0x7E to the Unicode 0x0020 to 0x007E code points) as these represent a security risk: browsers not supporting them may interpret benign content as HTML Elements. This is the case of at least the following charsets: JIS_C6226-1983, JIS_X0212-1990, HZ-GB-2312, JOHAB, the ISO-2022 family, and the EBCDIC family.
- Authors must not use CESU-8, UTF-7, BOCU-1 and SCSU, also falling in that category and not intended to be used on the web. Cross-scripting attacks with some of these encodings have been documented.
- Authors should not use UTF-32 because not all HTML5 encoding algorithms can distinguish it from UTF-16.
Here is also a link on UTF-8.
*Note: if for some reason UTF-8
encoding is not working for your characters, try charset="ISO-8859-1"
Upvotes: 2