Click here to Skip to main content
11,639,548 members (68,465 online)
Click here to Skip to main content

Tagged as

L33t Tr4nsl4t0r (Leet Translator)

, 13 Jun 2011 CPOL 5.3K 1
Rate this:
Please Sign up or sign in to vote.
Way too much code. Using arrays of characters, your switch constructs can be reduced to just a few lines of code, like so:switch (c) { case 'a': sb.Append("4"); break; case 'e': sb.Append("3"); break; case 'i': sb.Append("1"); break; ...
Way too much code. Using arrays of characters, your switch constructs can be reduced to just a few lines of code, like so:
switch (c)
         {
           case 'a': sb.Append("4"); break;
           case 'e': sb.Append("3"); break;
           case 'i': sb.Append("1"); break;
           case 'o': sb.Append("0"); break;
           case 'A': sb.Append("4"); break;
           case 'E': sb.Append("3"); break;
           case 'I': sb.Append("1"); break;
           case 'O': sb.Append("0"); break;
           default: sb.Append(c); break;
         }
becomes:
string rep="43104310";
int index= "aeioAEIO".IndexOf(c);
if (index<0) sb.Append(c);
else sb.Append(rep[index]);
where rep is used to further improve readability.
Smile | :)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Luc Pattyn
Software Developer (Senior) Perceler
Belgium Belgium
I am an engineer with a background in electronics, software and mathematics.

I develop technical software, both for embedded systems and for desktop equipment. This includes operating systems, communication software, local networks, image processing, machine control, automation, etc.

I have been using all kinds of microcontrollers and microprocessors (Intel 4004/8080/8051/80386/Pentium, Motorola 680x/680x0/ColdFire/PowerPC, Microchip PIC, Altera NIOS, and many more), lots of programming languages (all relevant assemblers, Fortran, Basic, C, Java, C#, and many more), and different operating systems (both proprietary and commercial).

For desktop applications and general development tools I have been using both UNIX systems and Mac/MacOS for many years, but I have switched to x86-based PCs with Windows, Visual Studio and the .NET Framework several years ago.

I specialize in:
- cross-platform development (making software that runs on diverse hardware/OS combinations)
- instruction set simulation
- improving software performance, i.e. making sure the software runs the job at hand in as short a time as possible on the given hardware. This entails algorithm selection, implementation design, accurate measurements, code optimisation, and sometimes implementing virtual machines, applying SIMD technology (such as MMX/SSE), and more.

You may also be interested in...

Comments and Discussions

 
GeneralRe: Thanks Luc :-) I will add an alternate. Pin
Kim Togo8-Jun-11 1:29
memberKim Togo8-Jun-11 1:29 
GeneralReason for my vote of 5 Fine version with simple code. Pin
thatraja13-Jun-11 19:53
mvpthatraja13-Jun-11 19:53 
GeneralRe: Thanks Raja. Pin
Kim Togo14-Sep-11 6:26
memberKim Togo14-Sep-11 6:26 
GeneralHi Luc. I have an updated version with the improvements you ... Pin
Kim Togo8-Jun-11 0:59
memberKim Togo8-Jun-11 0:59 
GeneralRe: I don't know what the expected action would be. Personally, ... Pin
Luc Pattyn8-Jun-11 1:27
mvpLuc Pattyn8-Jun-11 1:27 
GeneralReason for my vote of 5 Super approach Luc! I will try to co... Pin
Kim Togo7-Jun-11 20:44
memberKim Togo7-Jun-11 20:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150731.1 | Last Updated 13 Jun 2011
Article Copyright 2011 by Luc Pattyn
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid