Created
January 23, 2013 19:06
-
-
Save bhavanki/4611675 to your computer and use it in GitHub Desktop.
Page to emit character literal escape sequences in different programming languages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head><title>Character Escapes</title> | |
<style type="text/css"> | |
body { | |
font-family: sans-serif; | |
margin-top: 1in; | |
} | |
p { | |
font-size: large; | |
text-align: center; | |
} | |
table, input { | |
font-size: xx-large; | |
} | |
td { | |
padding: 0.5em; | |
} | |
input { | |
text-align: center; | |
} | |
.code { | |
font-family: monospace; | |
background-color: #eee; | |
} | |
.footer { | |
margin-top: 1in; | |
font-size: small; | |
} | |
</style> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> | |
<script> | |
var convert = function(chars) { | |
if (chars === "") { | |
$("#sgmlesc").html(""); | |
$("#jesc").html(""); | |
$("#pesc").html(""); | |
return true; | |
} | |
var code = chars.charCodeAt(0); | |
var hex = code.toString(16); | |
var hex4 = hex; | |
while (hex4.length < 4) { hex4 = "0" + hex4; } | |
$("#sgmlesc").html("&#" + code + ";"); | |
$("#jesc").html("\\u" + hex4); | |
$("#pesc").html("\\x" + hex); | |
return true; | |
} | |
</script> | |
</head> | |
<body> | |
<p> | |
Need a character escape sequence? | |
</p> | |
<table style="margin-left: auto; margin-right: auto"> | |
<tr> | |
<td>Character to escape</td> | |
<td><input type="text" size="1" onkeyup="convert(this.value)"></input> | |
</tr> | |
<tr> | |
<td>SGML (HTML, XML)</td> | |
<td class="code"><span id="sgmlesc"></span></td> | |
</tr> | |
<tr> | |
<td>Java / JavaScript / Python</td> | |
<td class="code"><span id="jesc"></span></td> | |
</tr> | |
<tr> | |
<td>Perl / Ruby / PHP / bash</td> | |
<td class="code"><span id="pesc"></span></td> | |
</tr> | |
</table> | |
<p> | |
Caution: Some languages do not support values greater than 255 / 0xff. | |
</p> | |
<p class="footer"> | |
by <a href="https://github.com/kbzod">Bill</a> | |
</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment