Why is "£" coming out as "£" when my HTML is rendered? - html

Code: http://pastebin.com/QBLeLyNq
I couldn't get the "code" thingy to work, thanks.
My error is here
Ran small business before. (£145 Profit, £6 Investment)
It is coming out as "£" on my site. I only know HTML and don't know too much about CSS or encoding. Could someone please explain to me why this is happening?

Try using £ for British Pound (and € for Euro).
You need to escape special characters in HTML, unless...
You address the encoding issue on a document-wide level by adding the following line of code at the beginning of the <head> section:
<meta charset="utf-8">
Then you don't need to escape special characters individually.
Further reading:
Character encodings for beginners
Declaring character encodings in HTML
Declaring character encodings in CSS

Use £
or specify the right encoding of your html file.
Add this in your <head>
<meta charset="UTF-8">
and you can use any special character without having to look for the html version.
This is assuming that your code editor is set to UTF-8 (which certainly is).

Related

Using HTML ASCII

Rookie question.
Would guys recommend using Html ASCII or does the browser handle this part? I was reading through W3Schools and I’m just curious if this is something I should always consider as a good habit.
It's always a good idea to include <meta charset="UTF-8"> in the <head> of your HTML documents. This lets the browser know that your document is encoded with Unicode.
It's perfectly fine to use Unicode characters in an HTML document, but it's better to use HTML entity names or entity numbers.
(see a list of entity names and numbers and learn more on
w3schools.)
According to w3schools,
If you use an HTML entity name or a hexadecimal number,
the character will always display correctly.
This is independent of what character set (encoding) your page uses!
This means that entity names and numbers are guaranteed to work, even if you don't put <meta charset="UTF-8"> in the <head> of the document.

£ sign not working in utf-8 charset (HTML5)

I recently updated a page I'm working on to work in HTML 5. For some reason when I changed my headers the £ sign that is included on all of the prices is no longer recognised and is showing as a white '?' in a black diamond.
Can anyone explain how to fix this? I have a feeling it has something to do with the <meta charset="utf-8"> line in my head, but could be mistaken.
Any help would be much appreciated!
Thanks!
You need to actually encode your HTML document in UTF-8. <meta charset="utf-8"> tells the browser that the document is supposedly encoded in UTF-8 and that the browser should treat it as such. A UTF-8 replacement character � means an invalid UTF-8 byte sequence was found at that point, which means your document is not actually encoded in UTF-8.
If you tell the browser it's UTF-8, then it must be UTF-8 that you send. It sounds like you're not sending valid UTF-8 sequences. You can probably fix this by doing one of the following:
Make sure you're saving the script(s) as UTF-8 in your editor. (Recommended)
Save the script(s) as ISO-8859-1, and use utf8_encode() on any output.

Single quotes showing as diamond shaped question mark in browsers (no database or PHP)

I am working with a web page in which I switched the character set from iso-8859-1 to utf-8. The top of the page reads like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>[title of site]</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
I am only using ASCII characters in the page, and since utf-8 encoding supersets ASCII, this should be fine. However, single quotes in the text are showing up as question marks surrounded by black diamonds. I have verified these are are ASCII single quotes (not straight quotes).
I've read much online that describes solutions to the problem that involve PHP, magic quotes, database configuration, etc. However, this is a flat HTML page that isn't being rendered by any programs.
Also, many who have this problem are told to switch to UTF-8 to fix the problem. This is exactly how I introduced the problem.
Please look at http://mch.blackcatwebinc.com/src/events.html to see this problem.
The only quotes in ASCII are the single quote ' (0x27 or 39) and the double quote " (0x22 or 33). What you have there is an 8-bit encoding that places quotes at 145 (0x91) and 146 (0x92) called CP1252; it's the standard 8-bit Western European encoding for Windows. If what you want is UTF-8, you need to convert that to UTF-8, since it's not valid UTF-8; valid UTF-8 uses multiple bytes for characters above 127 (0x7F), and places the opening and closing quotes at U+2018 and U+2019 respectively.
According to the W3C, the meta charset
should appear as close as possible to the top of the head element
From http://www.w3.org/International/questions/qa-html-encoding-declarations#metacontenttype
So, I might try to place the meta tag above the title.
Also, as mentioned in the first answer by #user1505373, UTF is always capitalized and there is no space after the = in any of the examples I saw.
Your source code is not saved in UTF-8 but Latin1 CP1252, and those quotes are not simple quotes but U+2019 RIGHT SINGLE QUOTATION MARKS (encoded in Latin1). Save the source file in UTF-8 and it'll work.
The simplest fix is to change UTF-8 to windows-1252 in the meta tag. This works, because the server announces no encoding in the Content-Type header, so browsers and other clients will use the one specified in a meta tag.
The name windows-1252 is the preferred MIME name for the 8-bit Windows Latin-1 encoding, also known as cp1252 and some other names (often misrepresented as “ANSI”).
As #deceze explains, the actual encoding of the data is windows-1252, not UTF-8. You can alternatively change the actual encoding to UTF-8 by saving the file with a suitable command in your authoring software. But what really matters is that the declared encoding matches the real one.
Yet another possibility is to use “escapes” for the apostrophe, such as ’. They work independently of encoding, but they make the source code less legible.
The only difference I see between your tag and the one on the site I'm working on is the space after the semicolon and that utf is lowercase on yours. Try capitalizing UTF.
All ASCII printable characters have their equivalent HTML Entity Code. Some of these characters are generally supported by most common OS typefaces, some are categorized as Symbols that bring us to your rendering issue.
What you supposedly have there is a closing single quote, and in order to get it rightly printed you should use it's entity code, or ’ respectively.
If it turns to be an opening single quote, then you should use ‘ instead.
Note, there's no HTML Entity Name for the two ASCII characters (and some more) so you're required to opt the entity code variant.

HTML - Arabic Support

i have a website in which i have to put some lines in Arabic.... how to do it...
where to get the Arabic text characters... how to make the page support Arabic...
i have to put a line per page and there is a lotta lotta pages so can't go around making images and putting them...
This is the answer that was required but everybody answered only part one of many.
Step 1 - You cannot have the multilingual characters in unicode document.. convert the document to UTF-8 document
advanced editors don't make it simple for you... go low level...
use notepad to save the document as meName.html & change the encoding
type to UTF-8
Step 2 - Mention in your html page that you are going to use such characters by
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
Step 3 - When you put in some characters make sure your container tags have the following 2 properties set
dir='rtl'
lang='ar'
Step 4 - Get the characters from some specific tool\editor or online editor like i did with Arabic-Keyboard.org
example
<p dir="rtl" lang="ar" style="color:#e0e0e0;font-size:20px;">رَبٍّ زِدْنٍي عِلمًا</p>
NOTE: font type, font family, font face setting will have no effect on special characters
The W3C has a good introduction.
In short:
HTML is a text markup language. Text means any characters, not just ones in ASCII.
Save your text using a character encoding that includes the characters you want (UTF-8 is a good bet). This will probably require configuring your editor in a way that is specific to the particular editor you are using. (Obviously it also requires that you have a way to input the characters you want)
Make sure your server sends the correct character encoding in the headers (how you do this depends on the server software you us)
If the document you serve over HTTP specifies its encoding internally, then make sure that is correct too
If anything happens to the document between you saving it and it being served up (e.g. being put in a database, being munged by a server side script, etc) then make sure that the encoding isn't mucked about with on the way.
You can also represent any unicode character with ASCII
You not only have to put the meta tag, telling that it is UTF-8 but really make the document UTF-8. You can do that with good editors (like notepad++) by converting them to "unicode" or "UTF-8 without BOM". Than you can simply use arabic characters
As this page is UTF-8, here are some examples (I hope I don't write anything rude here): شغف
If you use a server side scripting language make sure that it does not output the page in a different encoding. In PHP e.g. you can set it like this:
header('Content-Type: text/html; charset=utf-8');
If you don't even know where to get Arabic characters, but you want to display them, then you're doing something wrong.
Save files containing Arabic characters with encoding UTF-8. A good editor allows you to set the character encoding.
In the HTML page, place the following after <head>:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
If you're using XHTML:
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
That's it.
An alternative way (without messing with the encoding of a file), is using HTML escape sequences. This website does that jobs for you: http://www.htmlescape.net/
Won't you need the ensure the area where you display the Arabic is Right-to-Left orientated also?
e.g.
<p dir="rtl">
i edit the html page with notepad ++ ,set encoding to utf-8 and its work
As mentioned above, by default text editors will not use UTF-8 as the standard encoding for documents.
However most editors will allow you to change that in the settings. Even for each specific document.
Check you have <meta charset="utf-8"> inside head block.

How can I properly display German characters in HTML?

My pages contain German characters and I have typed the text in between the
HTML tag, but the browser views some characters differently. Do I need to include anything in HTML to properly display German characters?
<label> ausgefüllt </label>
It seems you need some basic explanations about something that unfortunately even most programmers don't understand properly.
Files like your HTML page are saved and transmitted over the Internet as a sequence of bytes, but you want them displayed as characters. In order to translate bytes into characters, you need a set of rules called a character encoding. Unfortunately, there are many different character encodings that have historically emerged to handle different languages. Most of them are based on the American ASCII encoding, but as soon as you have characters outside of ASCII such as German umlauts, you need to be very careful about which encoding you use.
The source of your problem is that in order to correctly decode an HTML file, the browser needs to know which encoding to use. You can tell it so in several ways:
The "Content-Type" HTTP header
The HTML META tag
The XML encoding attribute if you use XHTML
So you need to pick one encoding, save the HTML file using that encoding, and make sure that you declare that encoding in at least one of the ways listed above (and if you use more than one make damn sure they agree). As for what encoding to use, Germans often use ISO/IEC 8859-15, but UTF-8 is increasingly becoming the norm, and can handle any kind of non-ASCII characters at the same time.
UTF-8 is your friend.
Try
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
and check which encoding your webserver sends in the header.
If you use PHP, you can send your own headers in this way (you have to put this before any other output):
<?php header('Content-Type: text/html; charset=utf-8'); ?>
Also doublecheck that you saved your document in UTF-8.
Try the solution in blog post German characters encoding issue (2012-05-10):
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
Have you tried ü (ü) and Ü (Ü)?
You can find how to type other letters here.
Declare <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
and when saving the file, for example in notepad, choose the save as to be UTF-8 and not just .txt.
This should render the characters ok.
you may try utf8_encode() or utf8_decode() functions.Check if any of these works.
For example <?php echo utf8_encode('ausgefüllt'); ?>
Hope it will work.
Sounds like a character encoding issue, in that the file is saved as a different character encoding to what the webserver is saying it is.
I don't like the use of HTML entities (like %uuml;), they are only needed when there is something wrong with your characterset.
In short:
The RIGHT way is to fix your characterset.
The EASY way is to just use entities. You may not ever see any problems with this.
Tracking down characterset error can be very difficult. If you give us an URL where we can see the problem, we can probably give you a good hint where to look.
save as your file with UTF8, and use this META:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>