To convert the Chinese and Japanese to Unicodes of my own.

Standard

 Hi,

       Many of them would have struggled how to convert those for the HTML usages.

Use these codes in .html file.

What made me to do this?

I was doing I18N for my team, where we have to give the strings to the concerned person and we have to do then necessary steps for that.  This process usually takes around 2 to 3 days, which made driving into nuts for one string taking 3 days to convert. OMG a waste of time, energy, mail etc.  So wrote a code for that.  Ha ha ha, Simple ain’t it?

==============================================================================

<meta http-equiv=”content-type” content=”text/html; charset=utf-8″ />
<title>Unicode convertor for html files</title>
<html>
        <form name=”form” id=”form”>
                <textarea id=”unicode” rows=”10″ name=”unicode”></textarea><br>
                <input type=”button” value=”get the value” onmouseup=”getUnicode();”><br>
                <input type=”reset” value=”reset”><br>
                <textarea id=”output” name=”output” rows=”10″></textarea>
<script type=”text/javascript”>

        function getUnicode() {
   var tstr = document.getElementById(‘unicode’).value;
   var bstr = ”;
   for(var i=0; i<tstr.length; i++)
   {
        if(tstr.charCodeAt(i)>127)
        {
                bstr += ‘&#’ + tstr.charCodeAt(i) + ‘;’;
        }
        else{
                bstr += tstr.charAt(i);
        }
   }
   document.form.output.value = bstr;
}
</script>
</form>
</html>

======================================================================================

Charu

Advertisements

One response »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s