Wikipedia:AutoEd/fullwidth.js

//

//

function autoEdFullwidth(str) { //MAIN FUNCTION describes list of fixes

 //Spacing, periods and interpucts
  str = str.replace(/ /g, ' '); //fullwidth space
  //str = str.replace(/・/g, '·'); //fullwidth interpunct
  str = str.replace(/。/g, '.'); //replace ideographic period with a regular period (from TheFarix's AWB cleanup module)
  //str = str.replace(/・・・/g, '...'); //three interpuncts normally mean an ellipsis
  //str = str.replace(/···/g, '...'); //catch already converted triple interpuncts - it's after the interpunct rule so we only need one go-through to catch partial replacements
  str = str.replace(/…/g, '...'); //it's a little ballsy, I guess, but we're already doing lots of replacements, so... (see also [[WP:ELLIPSES]])

 //Common punctuation
  str = str.replace(/!/g, '!');
  str = str.replace(/(/g, '(');
  str = str.replace(/)/g, ')');
  str = str.replace(/?/g, '?');
 
 //Numbers
  str = str.replace(/0/g, '0');
  str = str.replace(/1/g, '1');
  str = str.replace(/2/g, '2');
  str = str.replace(/3/g, '3');
  str = str.replace(/4/g, '4');
  str = str.replace(/5/g, '5');
  str = str.replace(/6/g, '6');
  str = str.replace(/7/g, '7');
  str = str.replace(/8/g, '8');
  str = str.replace(/9/g, '9');
 
 //Latin letters, uppercase
  str = str.replace(/A/g, 'Α');
  str = str.replace(/B/g, 'B');
  str = str.replace(/C/g, 'C');
  str = str.replace(/D/g, 'D');
  str = str.replace(/E/g, 'E');
  str = str.replace(/F/g, 'F');
  str = str.replace(/G/g, 'G');
  str = str.replace(/H/g, 'H');
  str = str.replace(/I/g, 'I');
  str = str.replace(/J/g, 'J');
  str = str.replace(/K/g, 'K');
  str = str.replace(/L/g, 'L');
  str = str.replace(/M/g, 'M');
  str = str.replace(/N/g, 'N');
  str = str.replace(/O/g, 'O');
  str = str.replace(/P/g, 'P');
  str = str.replace(/Q/g, 'Q');
  str = str.replace(/R/g, 'R');
  str = str.replace(/S/g, 'S');
  str = str.replace(/T/g, 'T');
  str = str.replace(/U/g, 'U');
  str = str.replace(/V/g, 'V');
  str = str.replace(/W/g, 'W');
  str = str.replace(/X/g, 'X');
  str = str.replace(/Y/g, 'Y');
  str = str.replace(/Z/g, 'Z');
 
 //Latin letters, lowercase
  str = str.replace(/a/g, 'a');
  str = str.replace(/b/g, 'b');
  str = str.replace(/c/g, 'c');
  str = str.replace(/d/g, 'd');
  str = str.replace(/e/g, 'e');
  str = str.replace(/f/g, 'f');
  str = str.replace(/g/g, 'g');
  str = str.replace(/h/g, 'h');
  str = str.replace(/i/g, 'i');
  str = str.replace(/j/g, 'j');
  str = str.replace(/k/g, 'k');
  str = str.replace(/l/g, 'l');
  str = str.replace(/m/g, 'm');
  str = str.replace(/n/g, 'n');
  str = str.replace(/o/g, 'o');
  str = str.replace(/p/g, 'p');
  str = str.replace(/q/g, 'q');
  str = str.replace(/r/g, 'r');
  str = str.replace(/s/g, 's');
  str = str.replace(/t/g, 't');
  str = str.replace(/u/g, 'u');
  str = str.replace(/v/g, 'v');
  str = str.replace(/w/g, 'w');
  str = str.replace(/x/g, 'x');
  str = str.replace(/y/g, 'y');
  str = str.replace(/z/g, 'z');
 
 //Other punctuation
  str = str.replace(/"/g, '"');
  str = str.replace(/#/g, '#');
  str = str.replace(/$/g, '$');
  str = str.replace(/%/g, '%');
  str = str.replace(/&/g, '&');
  str = str.replace(/'/g, '\'');
  str = str.replace(/*/g, '*');
  str = str.replace(/+/g, '+');
  str = str.replace(/,/g, ', ');
  //str = str.replace(/、/g, ', '); //replace ideographic comma with a regular comma (from TheFarix's AWB cleanup module)
  str = str.replace(/-/g, '-');
  str = str.replace(/./g, '. ');
  str = str.replace(///g, '\/');
  str = str.replace(/:/g, ': ');
  str = str.replace(/;/g, '; ');
  str = str.replace(/</g, '<');
  str = str.replace(/=/g, '='); //this replacement could break template usage, use {{=}} as an alternative inside templates
  str = str.replace(/>/g, '>');
  str = str.replace(/@/g, '@');
  str = str.replace(/[/g, '['); //this replacement could break wikimarkup usage
  str = str.replace(/\/g, '\\');
  str = str.replace(/]/g, ']'); //this replacement could break wikimarkup usage
  str = str.replace(/^/g, '^');
  str = str.replace(/_/g, '_');
  str = str.replace(/`/g, '`');
  str = str.replace(/{/g, '{'); //this replacement could break wikimarkup usage, use {{(}} as an alternative
  str = str.replace(/|/g, '|'); //this replacement could break template usage, use {{!}} as an alternative inside templates
  str = str.replace(/}/g, '}'); //this replacement could break wikimarkup usage, use {{)}} as an alternative
  str = str.replace(/~/g, '〜'); //ASCII tilde is, apparently, treated as a diacritic in some fonts, so this should be a better replacement
  str = str.replace(/¢/g, '¢');
  str = str.replace(/£/g, '£');
  str = str.replace(/¬/g, '¬');
  str = str.replace(/¦/g, '¦');
  str = str.replace(/¥/g, '¥');
  str = str.replace(/₩/g, '₩');
  str = str.replace(/│/g, '│');
  str = str.replace(/←/g, '←');
  str = str.replace(/↑/g, '↑');
  str = str.replace(/→/g, '→');
  str = str.replace(/↓/g, '↓');
  str = str.replace(/■/g, '■');
  str = str.replace(/○/g, '○');
  str = str.replace(/『/g, '「'); //some Japanese quote replacement (from TheFarix's AWB cleanup module)
  str = str.replace(/』/g, '」'); //some Japanese quote replacement (from TheFarix's AWB cleanup module)

  return str;
}

//

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.