Skip to content

Instantly share code, notes, and snippets.

worker_processes 1;
error_log stderr;
pid nginx.pid;
daemon off;
events {
worker_connections 768;
}
http {
@dbodyas
dbodyas / decimal.js
Created February 12, 2012 15:30
JavaScript Get Unicode char as decimal
/*
Sometimes, unicode symbols that have to be inserted in an HTML page should be escaped.
For example, everybody know, that’s “&” should be escaped as “&”, ” ” as “ ” and so on.
But what, if you should insert symbol, that you never used before. So you don’t know how it should be present or escaped.
Code below, helps you to get valid decimal unicode for appropriate symbol.
*/
function getCharAsDecimalUTF8(char){
var getUTF8 = escape(char);
console.log("&#" + parseInt(getUTF8.substring(getUTF8.match(/\%u/) !== null ? 2 : 1), 16) + ";");
}