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(/０/g, '0'); str = str.replace(/１/g, '1'); str = str.replace(/２/g, '2'); str = str.replace(/３/g, '3'); str = str.replace(/４/g, '4'); str = str.replace(/５/g, '5'); str = str.replace(/６/g, '6'); str = str.replace(/７/g, '7'); str = str.replace(/８/g, '8'); str = str.replace(/９/g, '9'); //Latin letters, uppercase str = str.replace(/Ａ/g, 'Α'); str = str.replace(/Ｂ/g, 'B'); str = str.replace(/Ｃ/g, 'C'); str = str.replace(/Ｄ/g, 'D'); str = str.replace(/Ｅ/g, 'E'); str = str.replace(/Ｆ/g, 'F'); str = str.replace(/Ｇ/g, 'G'); str = str.replace(/Ｈ/g, 'H'); str = str.replace(/Ｉ/g, 'I'); str = str.replace(/Ｊ/g, 'J'); str = str.replace(/Ｋ/g, 'K'); str = str.replace(/Ｌ/g, 'L'); str = str.replace(/Ｍ/g, 'M'); str = str.replace(/Ｎ/g, 'N'); str = str.replace(/Ｏ/g, 'O'); str = str.replace(/Ｐ/g, 'P'); str = str.replace(/Ｑ/g, 'Q'); str = str.replace(/Ｒ/g, 'R'); str = str.replace(/Ｓ/g, 'S'); str = str.replace(/Ｔ/g, 'T'); str = str.replace(/Ｕ/g, 'U'); str = str.replace(/Ｖ/g, 'V'); str = str.replace(/Ｗ/g, 'W'); str = str.replace(/Ｘ/g, 'X'); str = str.replace(/Ｙ/g, 'Y'); str = str.replace(/Ｚ/g, 'Z'); //Latin letters, lowercase str = str.replace(/ａ/g, 'a'); str = str.replace(/ｂ/g, 'b'); str = str.replace(/ｃ/g, 'c'); str = str.replace(/ｄ/g, 'd'); str = str.replace(/ｅ/g, 'e'); str = str.replace(/ｆ/g, 'f'); str = str.replace(/ｇ/g, 'g'); str = str.replace(/ｈ/g, 'h'); str = str.replace(/ｉ/g, 'i'); str = str.replace(/ｊ/g, 'j'); str = str.replace(/ｋ/g, 'k'); str = str.replace(/ｌ/g, 'l'); str = str.replace(/ｍ/g, 'm'); str = str.replace(/ｎ/g, 'n'); str = str.replace(/ｏ/g, 'o'); str = str.replace(/ｐ/g, 'p'); str = str.replace(/ｑ/g, 'q'); str = str.replace(/ｒ/g, 'r'); str = str.replace(/ｓ/g, 's'); str = str.replace(/ｔ/g, 't'); str = str.replace(/ｕ/g, 'u'); str = str.replace(/ｖ/g, 'v'); str = str.replace(/ｗ/g, 'w'); str = str.replace(/ｘ/g, 'x'); str = str.replace(/ｙ/g, 'y'); str = str.replace(/ｚ/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; }