Skip to content

Instantly share code, notes, and snippets.

@teetteet
Created December 27, 2012 03:12
Show Gist options
  • Save teetteet/4385149 to your computer and use it in GitHub Desktop.
Save teetteet/4385149 to your computer and use it in GitHub Desktop.
A CodePen by goker cebeci. ESCAPE IT! - char to escapechar with JavaScript
<h1>escape it!</h1>
<input name="char" value="ğ" />
<code id="escaped">%u011F</code>
$('input[name=char]').on('keyup', function(){
var c = $(this).val();
if(c.length > 1)
c = c.charAt(1);
$(this).val(c);
$('#escaped').html(escape(c));
});
$('input[name=char]').focus();
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
body, html {
font-family: 'Ubuntu', sans-serif;
color: #000;
background: WhiteSmoke;
text-align: center;
}
h1 {
font-size: 48px;
font-weight: bold;
margin: 40px 0 10px;
position: relative;
text-align: center;
text-transform: uppercase;
text-shadow: 0 0 2px #000;
z-index: 0;
}
input, code {
display: block;
margin: 5px auto;
padding: 5px 10px;
width: 210px;
color: #ddd;
font-size: 40px;
font-family: 'Ubuntu', sans-serif;
text-align: center;
text-shadow: 0 0 2px #fff;
border: 1px solid #666;
background: #000;
border-radius: 3px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment