Cycymomo
8/1/2013 - 9:21 AM

140bytes - Converts a latin character string into [leetspeak]

140bytes - Converts a latin character string into [leetspeak]

<!DOCTYPE html> 
<title>Leet 140byt.es</title>
<style>
  #output { font-family: monospace; width: 400px; font-size: 16px;}
  #input { width: 400px; height: 30px; display: block;}
  button { margin: 1em 0;}
</style>

<textarea id="input">
140byt.es is a tweet-sized, fork-to-play, community-curated collection of JavaScript.

Go to the master gist page, and click the  button.
1. Modify all the files to according to the rules in the gist.
2. Save your entry and tweet it up!
3. Keep in mind that thanks to the awesome sensibilities of the GitHub team, gists are just repos. So feel free to clone yours and work locally for a more comfortable environment, and to allow commit messages.  
</textarea>

<button onclick="convert()">-> LEET -></button>

<div id="output"></div>

<script>
  var leet = function f(a){return"4BCD3F6H1JKLMN0PQR57"[parseInt(a,36)-10]||a.replace(/[a-t]/gi,f)}
  function convert(){
    document.getElementById( "output" ).innerHTML = leet(document.getElementById( "input" ).value);
  }
  
  convert();
  
</script>
{
  "name": "leet",

  "description": "Converts a latin character string into leetspeak.",

  "keywords": [
    "string",
    "1337",
    "ascii"
  ]
}
function f(a){return"4BCD3F6H1JKLMN0PQR57"[parseInt(a,36)-10]||a.replace(/[a-t]/gi,f)}
function f(                           // callback for replace
  a                                   // input string or character to replace
){
  return "4BCD3F6H1JKLMN0PQR57"[      
    parseInt(a, 36)                   // get code of character
    -10                               // shift "A" to 0
  ] || a.replace(                     // replace characters in input string
    /[a-t]/gi,                        // ignore case
    f                                 
  )                                   
}                                     

Leet - 140byt.es

Converts a latin character string into leetspeak.

Example output

140By7.35 15 4 7w337-51z3D, F0RK-70-PL4y, C0MMuN17y-CuR473D 
C0LL3C710N 0F J4v45CR1P7. 60 70 7H3 M4573R 6157 P463, 4ND 
CL1CK 7H3 Bu770N. 1. M0D1Fy 4LL 7H3 F1L35 70 4CC0RD1N6 70 
7H3 RuL35 1N 7H3 6157. 2. 54v3 y0uR 3N7Ry 4ND 7w337 17 uP! 
3. K33P 1N M1ND 7H47 7H4NK5 70 7H3 4w350M3 53N51B1L17135 0F 
7H3 617HuB 734M, 61575 4R3 Ju57 R3P05. 50 F33L FR33 70 CL0N3 
y0uR5 4ND w0RK L0C4LLy F0R 4 M0R3 C0MF0R74BL3 3Nv1R0NM3N7, 
4ND 70 4LL0w C0MM17 M3554635.

For more information

See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter.

To learn about byte-saving hacks for your own code, or to contribute what you've learned, head to the wiki.

140byt.es is brought to you by Jed Schmidt, with help from Alex Kloss. It was inspired by work from Thomas Fuchs and Dustin Diaz.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.