MediaWiki

MediaWiki:UniToASCII.js

Revision as of 16:40, 10 June 2008 by Acyuta (talk | contribs) (New page: →‎*** Function to Convert Unicode to ASCII ***: UniToASCII = function(obj) { obj = obj.replace(/ā/g, "a"); // long a o...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.

        /****   Function to Convert Unicode to ASCII    ****/
        
        UniToASCII = function(obj) {
            
            obj = obj.replace(/ā/g, "a"); // long a
            obj = obj.replace(/ī/g, "i"); // long i
            obj = obj.replace(/ū/g, "u"); // long u
            obj = obj.replace(/ṛ/g, "r"); // r cedilla
            obj = obj.replace(/ṟ/g, "r"); // long r cedilla
            obj = obj.replace(/ṅ/g, "n"); // n dot over
        
            obj = obj.replace(/ṣ/g, "s"); // s cedilla
            obj = obj.replace(/ñ/g, "n"); // n tilde
        
            obj = obj.replace(/ṭ/g, "t"); // t cedilla
            obj = obj.replace(/ḍ/g, "d"); // d cedilla
            obj = obj.replace(/ṇ/g, "n"); // n cedilla
            obj = obj.replace(/ś/g, "s"); // s accent
        
            obj = obj.replace(/ṁ/g, "m"); // m dot over (anusvara)
            obj = obj.replace(/ḥ/g, "h"); // h cedilla (visarga)
            obj = obj.replace(/ḷ/g, "l"); // l cedilla
            obj = obj.replace(/ḻ/g, "l"); // long l cedilla
        
            obj = obj.replace(/Ā/g, "A"); // long a
            obj = obj.replace(/Ī/g, "I"); // long i
            obj = obj.replace(/Ū/g, "U"); // long u
            obj = obj.replace(/Ṛ/g, "R"); // r cedilla
            obj = obj.replace(/Ṟ/g, "R"); // long r cedilla
            obj = obj.replace(/Ṅ/g, "N"); // n dot over
        
            obj = obj.replace(/Ṣ/g, "S"); // s cedilla
            obj = obj.replace(/Ñ/g, "N"); // n tilde
        
            obj = obj.replace(/Ṭ/g, "T"); // t cedilla
            obj = obj.replace(/Ḍ/g, "D"); // d cedilla
            obj = obj.replace(/Ṇ/g, "N"); // n cedilla
            obj = obj.replace(/Ś/g, "S"); // s accent
        
            obj = obj.replace(/Ṁ/g, "M"); // m dot over (anusvara)
            obj = obj.replace(/Ḥ/g, "H"); // h cedilla (visarga)
            obj = obj.replace(/Ḷ/g, "L"); // l cedilla 
            
            return obj;
        }