Last active
October 12, 2017 19:37
-
-
Save mohanmca/f18eae05b87b1bc43df7fcd9d490f6ec to your computer and use it in GitHub Desktop.
Revisions
-
mohanmca revised this gist
Oct 12, 2017 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -36,4 +36,23 @@ for(var i=0;i<128;i++) { var newCharInHex = newChar.toString(16) console.log(convertHexToString(newCharInHex)) } ``` Generate Tamil char using unicode ```Javascript function convertToUtf8(s) { function parse(a, c) { return String.fromCharCode(parseInt(c, 16)); } return encodeURIComponent(s.replace(/%u([0-f]{4})/gi, parse)); } var tamilBaseChar = parseInt("B80", 16) for(var i=0;i<128;i++) { var newChar = tamilBaseChar + i var newCharInHex = (newChar).toString(16) var tamilUnicodeHex = "0x0" + newCharInHex var tamilChar = String.fromCodePoint("0x0" + newCharInHex) console.log(tamilUnicodeHex + " ~~ " + tamilChar + " ~~ UTF8 ~~> " + convertToUtf8(tamilChar)) } ``` -
mohanmca revised this gist
Oct 11, 2017 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,12 @@ பி - TAMIL LETTER PA - Hex UTF-8 bytes - E0 AE AA டி - TAMIL LETTER TTA - Hex UTF-8 bytes - E0 AE 9F http://www.utf8-chartable.de/unicode-utf8-table.pl?start=2944&number=128&utf8=0x starts from - U+0B80 - 0xe0 0xae 0x80 ends until - U+0BFF - 0xe0 0xaf 0xbf >> 128 tamil utf-8 characters ```Javascript function convertHexToString(input) { @@ -20,7 +29,6 @@ function convertHexToString(input) { console.log("'" + convertHexToString('c385') + "'"); // => 'Å' console.log("'" + convertHexToString('E0AEAA') + "'"); for(var i=0;i<128;i++) { var tamilChar = parseInt("E0AEAA", 16) -
mohanmca created this gist
Oct 11, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ ```Javascript function convertHexToString(input) { // split input into groups of two var hex = input.match(/[\s\S]{2}/g) || []; var output = ''; // build a hex-encoded representation of your string for (var i = 0, j = hex.length; i < j; i++) { output += '%' + ('0' + hex[i]).slice(-2); } // decode it using this trick output = decodeURIComponent(output); return output; } console.log("'" + convertHexToString('c385') + "'"); // => 'Å' console.log("'" + convertHexToString('E0AEAA') + "'"); >> 128 tamil utf-8 characters for(var i=0;i<128;i++) { var tamilChar = parseInt("E0AEAA", 16) var newChar = tamilChar + i var newCharInHex = newChar.toString(16) console.log(convertHexToString(newCharInHex)) } ```