I saw this code snippet in an article about character encodings.
<html>
<body>
<style type="text/css">p {float: left; padding: 0 15px; margin: 0; font-size: 80%;}</style>
<script type="text/javascript">
for (var i=0; i<128; i ) document.writeln ((i%32?’:'<p>') i ': ' String.fromCharCode (i) '<br>');
</script>
</body>
</html>
The code is supposed to output all ASCII characters in the specified range.
In the for-loop body, in the writeln
function, there is an apostrophe after the modulo condition. I don't understand what the apostrophe means. I copied it to my text editor and saved it as a HTML file but it does not render anything on my browser. It produces a syntax error in the console Uncaught SyntaxError: Invalid or unexpected token
.
Here is a link to the article - https://www.smashingmagazine.com/2012/06/all-about-unicode-utf8-character-sets/
CodePudding user response:
You can alternatively use single character enclosing tags in place of apostrophe like this. It produces same result as the given in article i.e from 33 to 126.
for (var i=0; i<128; i )
document.writeln ((i%32?'':'<p>') i ': '
String.fromCharCode (i) '<br>');
p {float: left; padding: 0 15px; margin: 0; font-size: 80%;}
<html>
<body></body>
</html>