Forum Moderators: open

Message Too Old, No Replies

Character Coding

         

missashlay

6:05 am on Nov 25, 2008 (gmt 0)

10+ Year Member



I have these little question marks in place of quotation marks throughout my coding. Is there anyway that I can get rid of them?

<meta http-equiv="content-type" content="text/html;charset=utf-8" />

Is my character code.

tedster

7:49 am on Nov 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello missashlay, and welcome to the forums.

Are those question marks showing up on your visible page in the browser, or in the code itself?

The problem usually comes from using copy/paste into your web page from some other source, such as an editor that places so-called smart quotes or angled quotes. In your mark-up, for things like class names and so on, you want to use straight quotes. That is a different computer code (actually a different character) than either the curly open or close quote characters.

When software has no access to a font that displays the angled, smart quotes, then it will display something like a question mark or a small square instead to hold the position and indicate that there is a problem.

lavazza

10:08 am on Nov 25, 2008 (gmt 0)

10+ Year Member



This issue annoyed me so much that I cobbled together a (rather ugly, yet effective) script to convert curly quotes (and a whole bunch of other (typically) word-processor generated schmutz) into utf-8

For ease of copying, I'll paste it into the next post

lavazza

10:09 am on Nov 25, 2008 (gmt 0)

10+ Year Member



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>utf-8 converter</title>
<script type="text/javascript">
var myErrorPrompt01 ="\nPlease type (or paste) something to be converted into UTF-8\n";
function selectAll()
{// maybe not the most elegant solution but it works
document.myForm.myOutput.focus();
document.myForm.myOutput.select();
CopiedTxt = document.selection.createRange();
}
function findAndReplace(myInput)
{
encodeMyInput(myInput);
selectAll();
}
function refresh()
{// dwisontt
window.location.reload(false);
}
function myResetAll(myI, sTB)
{
myI.disabled=false;
sTB.checked = false;
refresh();
}
function encodeMyInput(myInput)
{
var myInput = document.myForm.myInput.value;
var myOutput = "";
if (myInput == "")
{
alert(myErrorPrompt01);
}
else
{
myInput.disabled = false;
var regLength = myInput.length;
for (i = 0; i < regLength; i++)
{
var charCode = "000";
var curChar = myInput.charAt(i);
if (curChar == "Á"){charCode = "&Aacute;";}
if (curChar == "Â"){charCode = "&Acirc;";}
if (curChar == "Ä"){charCode = "&Auml;";}
if (curChar == "À"){charCode = "&Agrave;";}
if (curChar == "Å"){charCode = "&Aring;";}
if (curChar == "Ã"){charCode = "&Atilde;";}
if (curChar == "á"){charCode = "&aacute;";}
if (curChar == "â"){charCode = "&acirc;";}
if (curChar == "ä"){charCode = "&auml;";}
if (curChar == "à"){charCode = "&agrave;";}
if (curChar == "å"){charCode = "&aring;";}
if (curChar == "ã"){charCode = "&atilde;";}
if (curChar == "Æ"){charCode = "&AElig;";}
if (curChar == "æ"){charCode = "&aelig;";}
if (curChar == "ß"){charCode = "&beta;";}
if (curChar == "Ç"){charCode = "&Ccedil;";}
if (curChar == "ç"){charCode = "&ccedil;";}
if (curChar == "É"){charCode = "&Eacute;";}
if (curChar == "Ê"){charCode = "&Ecirc;";}
if (curChar == "Ë"){charCode = "&Euml;";}
if (curChar == "È"){charCode = "&Egrave;";}
if (curChar == "é"){charCode = "&eacute;";}
if (curChar == "ê"){charCode = "&ecirc;";}
if (curChar == "ë"){charCode = "&euml;";}
if (curChar == "è"){charCode = "&egrave;";}
if (curChar == "Ð"){charCode = "&ETH;";}
if (curChar == "ð"){charCode = "&eth;";}
if (curChar == "ƒ"){charCode = "&fnof;";}
if (curChar == "Í"){charCode = "&Iacute;";}
if (curChar == "Î"){charCode = "&Icirc;";}
if (curChar == "Ï"){charCode = "&Iuml;";}
if (curChar == "Ì"){charCode = "&Igrave;";}
if (curChar == "í"){charCode = "&iacute;";}
if (curChar == "î"){charCode = "&icirc;";}
if (curChar == "ï"){charCode = "&iuml;";}
if (curChar == "ì"){charCode = "&igrave;";}
if (curChar == "µ"){charCode = "&mu;";}
if (curChar == "Ñ"){charCode = "&Ntilde;";}
if (curChar == "ñ"){charCode = "&ntilde;";}
if (curChar == "Ó"){charCode = "&Oacute;";}
if (curChar == "Ô"){charCode = "&Ocirc;";}
if (curChar == "Ö"){charCode = "&Ouml;";}
if (curChar == "Ò"){charCode = "&Ograve;";}
if (curChar == "Ø"){charCode = "&Oslash;";}
if (curChar == "Õ"){charCode = "&Otilde;";}
if (curChar == "ó"){charCode = "&oacute;";}
if (curChar == "ô"){charCode = "&ocirc;";}
if (curChar == "ö"){charCode = "&ouml;";}
if (curChar == "ò"){charCode = "&ograve;";}
if (curChar == "ø"){charCode = "&oslash;";}
if (curChar == "õ"){charCode = "&otilde;";}
if (curChar == "Œ"){charCode = "&OElig;";}
if (curChar == "œ"){charCode = "&oelig;";}
if (curChar == "Š"){charCode = "&Scaron;";}
if (curChar == "š"){charCode = "&scaron;";}
if (curChar == "ß"){charCode = "&szlig;";}
if (curChar == "Þ"){charCode = "&THORN;";}
if (curChar == "þ"){charCode = "&thorn;";}
if (curChar == "Ú"){charCode = "&Uacute;";}
if (curChar == "Û"){charCode = "&Ucirc;";}
if (curChar == "Ü"){charCode = "&Uuml;";}
if (curChar == "Ù"){charCode = "&Ugrave;";}
if (curChar == "ú"){charCode = "&uacute;";}
if (curChar == "û"){charCode = "&ucirc;";}
if (curChar == "ü"){charCode = "&uuml;";}
if (curChar == "ù"){charCode = "&ugrave;";}
if (curChar == "Ý"){charCode = "&Yacute;";}
if (curChar == "Ÿ"){charCode = "&Yuml;";}
if (curChar == "ý"){charCode = "&yacute;";}
if (curChar == "ÿ"){charCode = "&yuml;";}
if (curChar == "¢"){charCode = "&cent;";}
if (curChar == "¤"){charCode = "&curren;";}
if (curChar == "€"){charCode = "&euro;";}
if (curChar == "£"){charCode = "&pound;";}
if (curChar == "¥"){charCode = "&yen;";}
if (curChar == "˜"){charCode = "&asymp;";}
if (curChar == "°"){charCode = "&deg;";}
if (curChar == "÷"){charCode = "&divide;";}
if (curChar == "·"){charCode = "&sdot;";}
if (curChar == "Ø"){charCode = "&empty;";}
if (curChar == "ª"){charCode = "&ordf;";}
if (curChar == ">"){charCode = "&gt;";}
if (curChar == "<"){charCode = "&lang;";}
if (curChar == "«"){charCode = "&laquo;";}
if (curChar == "<"){charCode = "&lt;";}
if (curChar == "º"){charCode = "&ordm;";}
if (curChar == "µ"){charCode = "&micro;";}
if (curChar == "×"){charCode = "&times;";}
if (curChar == "¬"){charCode = "&not;";}
if (curChar == "‰"){charCode = "&permil;";}
if (curChar == "±"){charCode = "&plusmn;";}
if (curChar == "'"){charCode = "&prime;";}
if (curChar == ">"){charCode = "&rang;";}
if (curChar == "»"){charCode = "&raquo;";}
if (curChar == "§"){charCode = "&sect;";}
if (curChar == "¹"){charCode = "&sup1;";}
if (curChar == "³"){charCode = "&sup3;";}
if (curChar == "²"){charCode = "&sup2;";}
if (curChar == "~"){charCode = "&sim;";}
if (curChar == "½"){charCode = "&frac12;";}
if (curChar == "¼"){charCode = "&frac14;";}
if (curChar == "¾"){charCode = "&frac34;";}
if (curChar == "´"){charCode = "&acute;";}
if (curChar == "¸"){charCode = "&cedil;";}
if (curChar == "¨"){charCode = "&uml;";}
if (curChar == "„"){charCode = "&bdquo;";}
if (curChar == "…"){charCode = "&hellip;";}
if (curChar == "¡"){charCode = "&iexcl;";}
if (curChar == "¿"){charCode = "&iquest;";}
if (curChar == "“"){charCode = "&ldquo;";}
if (curChar == "‘"){charCode = "&lsquo;";}
if (curChar == "¯"){charCode = "&macr;";}
if (curChar == "·"){charCode = "&middot;";}
if (curChar == "ˆ"){charCode = "&circ;";}
if (curChar == "“"){charCode = "&ldquo;";}
if (curChar == "”"){charCode = "&rdquo;";}
if (curChar == "’"){charCode = "&rsquo;";}
if (curChar == "‚"){charCode = "&sbquo;";}
if (curChar == "˜"){charCode = "&tilde;";}
if (curChar == "­"){charCode = "&shy;";}
if (curChar == "©"){charCode = "&copy;";}
if (curChar == "†"){charCode = "&dagger;";}
if (curChar == "‡"){charCode = "&Dagger;";}
if (curChar == "¶"){charCode = "&para;";}
if (curChar == "®"){charCode = "&reg;";}
if (curChar == "™"){charCode = "&trade;";}
if (curChar == "&"){charCode = "&amp;";}
if (curChar == "¦"){charCode = "&brvbar;";}
if (curChar == "•"){charCode = "&bull;";}
if (curChar == "—"){charCode = "&mdash;";}
if (curChar == "–"){charCode = "&ndash;";}
if (charCode == "000")
{
myOutput += curChar;
}
else
{
myOutput += charCode;
}
}
document.myForm.myOutput.value = myOutput;
}
}
</script>
</head>
<body>
<h1>
utf-8 convert
</h1>
<p>
Find <em>non-standard UNICODE Consortium</em> characters and Replace them with the nearest equivalent UTF-8 character
</p>
<form name="myForm"
id="myForm"
action="get">
<noscript><p>To use this feature, javascript must be enabled on your machine</p></noscript>
<p>
Type (or paste) the word(s) to be converted to utf-8 here:
<br>
<textarea name="myInput"
rows="5"
cols="100"
id="myInput"></textarea>
</p>
<p>
Click the button:
</p>
<p>
<input type="button"
name="btnFnR"
id="btnFnR"
value=" &nbsp; Find and Replace &nbsp;"
onclick="findAndReplace(myInput);">
</p>
<p>
Then copy what appears here:
</p>
<p>
<textarea name="myOutput"
rows="5"
cols="100"
id="myOutput"></textarea>
</p>
<p>
<input type="reset"
name="namebtnReset"
id="idBtnReset"
value=" &nbsp;Reset &nbsp;"
onclick="myResetAll(myInput, myOutput);">
</p>
</form>
</body>
</html>