Results 1 to 3 of 3

Thread: [RESOLVED] Text Flip

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Resolved [RESOLVED] Text Flip

    I was makeing this on a whim to play a joke on my buddy at work.


    Thought i would throw the source out here to see if anyone else can have a good time pranking the helpdesk or other coworkers

    c# Code:
    1. private string flip(char Ch)
    2.         {
    3.             string st = Ch.ToString();
    4.  
    5.             switch (st.ToLower())
    6.             {
    7.                 case "a":
    8.                     return "\u0250";
    9.                    
    10.                 case "b":
    11.                     return "\u0071";
    12.                    
    13.                 case "c":
    14.                     return "\u0254";
    15.                
    16.                 case "d":
    17.                     return "\u0070";
    18.                    
    19.                 case "e":
    20.                     return "\u01DD";
    21.  
    22.                 case "f":
    23.                     return "\u025F";
    24.  
    25.                 case "g":
    26.                     return "\u0183";
    27.  
    28.                 case "h":
    29.                     return "\u0265";
    30.  
    31.                 case "i":
    32.                     return "\u0131";
    33.  
    34.                 case "j":
    35.                     return "\u027E";
    36.  
    37.                 case "k":
    38.                     return "\u029E";
    39.  
    40.                 case "l":
    41.                     return "\u006C";
    42.  
    43.                 case "m":
    44.                     return "\u026F";
    45.  
    46.                 case "n":
    47.                     return "\u0075";
    48.  
    49.                 case "o":
    50.                     return "\u006F";
    51.  
    52.                 case "p":
    53.                     return "\u0064";
    54.  
    55.                 case "q":
    56.                     return "\u0062";
    57.  
    58.                 case "r":
    59.                     return "\u0279";
    60.  
    61.                 case "s":
    62.                     return "\u0073";
    63.  
    64.                 case "t":
    65.                     return "\u0287";
    66.  
    67.                 case "u":
    68.                     return "\u006E";
    69.  
    70.                 case "v":
    71.                     return "\u028C";
    72.  
    73.                 case "w":
    74.                     return "\u028D";
    75.  
    76.                 case "x":
    77.                     return "\u0078";
    78.  
    79.                 case "y":
    80.                     return "\u028E";
    81.  
    82.                 case "z":
    83.                     return "\u007A";
    84.  
    85.             }
    86.             return Ch.ToString();
    87.         }
    88.  
    89.         private void FormatString()
    90.         {
    91.             string replace = "";
    92.  
    93.  
    94.             foreach (char Ch in TB_Up.Text)
    95.             {
    96.                 replace += flip(Ch);
    97.             }
    98.  
    99.             string holding = "";
    100.             foreach (char Chx in replace)
    101.             {
    102.  
    103.                 holding = Chx + holding;
    104.             }
    105.             replace = holding;
    106.             TB_Down.Clear();
    107.             TB_Down.Text = replace;
    108.         }
    109.         private void TB_Up_KeyUp(object sender, KeyEventArgs e)
    110.         {
    111.             FormatString();  
    112.         }
    113.     }
    114. }


    as always if you see somewhere that needs improvement.

    C# Code:
    1. }
    2.  
    3. }    
    4.  
    5. }        
    6.  
    7.   ;)(ƃuıɹʇsʇɐɯɹoɟ            
    8.  
    9. {        
    10.  
    11. )ǝ sƃɹɐʇuǝʌǝʎǝʞ ,ɹǝpuǝs ʇɔǝɾqo(dnʎǝʞ_dn_qʇ pıoʌ ǝʇɐʌıɹd        
    12.  
    13. }        
    14.  
    15. ;ǝɔɐldǝɹ = ʇxǝʇ.uʍop_qʇ            
    16.  
    17. ;)(ɹɐǝlɔ.uʍop_qʇ            
    18.  
    19. ;ƃuıploɥ = ǝɔɐldǝɹ            
    20.  
    21. }            
    22.  
    23. ;ƃuıploɥ + xɥɔ = ƃuıploɥ                
    24.  
    25.  
    26. {            
    27.  
    28. )ǝɔɐldǝɹ uı xɥɔ ɹɐɥɔ( ɥɔɐǝɹoɟ            
    29.  
    30. ;"" = ƃuıploɥ ƃuıɹʇs            
    31.  
    32.  
    33. }            
    34.  
    35. ;)ɥɔ(dılɟ =+ ǝɔɐldǝɹ                
    36.  
    37. {            
    38.  
    39. )ʇxǝʇ.dn_qʇ uı ɥɔ ɹɐɥɔ( ɥɔɐǝɹoɟ            
    40.  
    41.  
    42.  
    43. ;"" = ǝɔɐldǝɹ ƃuıɹʇs            
    44.  
    45. {        
    46.  
    47. )(ƃuıɹʇsʇɐɯɹoɟ pıoʌ ǝʇɐʌıɹd        
    48.  
    49.  
    50. }        
    51.  
    52. ;)(ƃuıɹʇsoʇ.ɥɔ uɹnʇǝɹ            
    53.  
    54. }            
    55.  
    56.  
    57. ;"ɐ700n\" uɹnʇǝɹ                    
    58.  
    59. :"z" ǝsɐɔ                
    60.  
    61.  
    62. ;"ǝ820n\" uɹnʇǝɹ                    
    63.  
    64. :"ʎ" ǝsɐɔ                
    65.  
    66.  
    67. ;"8700n\" uɹnʇǝɹ                    
    68.  
    69. :"x" ǝsɐɔ                
    70.  
    71.  
    72. ;"p820n\" uɹnʇǝɹ                    
    73.  
    74. :"ʍ" ǝsɐɔ                
    75.  
    76.  
    77. ;"ɔ820n\" uɹnʇǝɹ                    
    78.  
    79. :"ʌ" ǝsɐɔ                
    80.  
    81.  
    82. ;"ǝ600n\" uɹnʇǝɹ                    
    83.  
    84. :"n" ǝsɐɔ                
    85.  
    86.  
    87. ;"7820n\" uɹnʇǝɹ                    
    88.  
    89. :"ʇ" ǝsɐɔ                
    90.  
    91.  
    92. ;"3700n\" uɹnʇǝɹ                    
    93.  
    94. :"s" ǝsɐɔ                
    95.  
    96.  
    97. ;"9720n\" uɹnʇǝɹ                    
    98.  
    99. :"ɹ" ǝsɐɔ                
    100.  
    101.  
    102. ;"2600n\" uɹnʇǝɹ                    
    103.  
    104. :"b" ǝsɐɔ                
    105.  
    106.  
    107. ;"4600n\" uɹnʇǝɹ                    
    108.  
    109. :"d" ǝsɐɔ                
    110.  
    111.  
    112. ;"ɟ600n\" uɹnʇǝɹ                    
    113.  
    114. :"o" ǝsɐɔ                
    115.  
    116.  
    117. ;"5700n\" uɹnʇǝɹ                    
    118.  
    119. :"u" ǝsɐɔ                
    120.  
    121.  
    122. ;"ɟ620n\" uɹnʇǝɹ                    
    123.  
    124. :"ɯ" ǝsɐɔ                
    125.  
    126.  
    127. ;"ɔ600n\" uɹnʇǝɹ                    
    128.  
    129. :"l" ǝsɐɔ                
    130.  
    131.  
    132. ;"ǝ920n\" uɹnʇǝɹ                    
    133.  
    134. :"ʞ" ǝsɐɔ                
    135.  
    136.  
    137. ;"ǝ720n\" uɹnʇǝɹ                    
    138.  
    139. :"ɾ" ǝsɐɔ                
    140.  
    141.  
    142. ;"1310n\" uɹnʇǝɹ                    
    143.  
    144. :"ı" ǝsɐɔ                
    145.  
    146.  
    147. ;"5620n\" uɹnʇǝɹ                    
    148.  
    149. :"ɥ" ǝsɐɔ                
    150.  
    151.  
    152. ;"3810n\" uɹnʇǝɹ                    
    153.  
    154. :"ƃ" ǝsɐɔ                
    155.  
    156.  
    157. ;"ɟ520n\" uɹnʇǝɹ                    
    158.  
    159. :"ɟ" ǝsɐɔ                
    160.  
    161.  
    162. ;"pp10n\" uɹnʇǝɹ                    
    163.  
    164. :"ǝ" ǝsɐɔ                
    165.  
    166.                    
    167.  
    168. ;"0700n\" uɹnʇǝɹ                    
    169.  
    170. :"p" ǝsɐɔ                
    171.  
    172.                
    173.  
    174. ;"4520n\" uɹnʇǝɹ                    
    175.  
    176. :"ɔ" ǝsɐɔ                
    177.  
    178.                    
    179.  
    180. ;"1700n\" uɹnʇǝɹ                    
    181.  
    182. :"q" ǝsɐɔ                
    183.  
    184.                    
    185.  
    186. ;"0520n\" uɹnʇǝɹ                    
    187.  
    188. :"ɐ" ǝsɐɔ                
    189.  
    190. {            
    191.  
    192. ))(ɹǝʍoloʇ.ʇs( ɥɔʇıʍs            
    193.  
    194.  
    195. ;)(ƃuıɹʇsoʇ.ɥɔ = ʇs ƃuıɹʇs            
    196.  
    197. {        
    198.  
    199. )ɥɔ ɹɐɥɔ(dılɟ ƃuıɹʇs ǝʇɐʌıɹd

  2. #2
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,547

    Re: Text Flip

    Quote Originally Posted by Crash893
    I was makeing this on a whim to play a joke on my buddy at work.


    Thought i would throw the source out here to see if anyone else can have a good time pranking the helpdesk or other coworkers

    c# Code:
    1. private string flip(char Ch)
    2.         {
    3.             string st = Ch.ToString();
    4.  
    5.             switch (st.ToLower())
    6.             {
    7.                 case "a":
    8.                     return "\u0250";
    9.                    
    10.                 case "b":
    11.                     return "\u0071";
    12.                    
    13.                 case "c":
    14.                     return "\u0254";
    15.                
    16.                 case "d":
    17.                     return "\u0070";
    18.                    
    19.                 case "e":
    20.                     return "\u01DD";
    21.  
    22.                 case "f":
    23.                     return "\u025F";
    24.  
    25.                 case "g":
    26.                     return "\u0183";
    27.  
    28.                 case "h":
    29.                     return "\u0265";
    30.  
    31.                 case "i":
    32.                     return "\u0131";
    33.  
    34.                 case "j":
    35.                     return "\u027E";
    36.  
    37.                 case "k":
    38.                     return "\u029E";
    39.  
    40.                 case "l":
    41.                     return "\u006C";
    42.  
    43.                 case "m":
    44.                     return "\u026F";
    45.  
    46.                 case "n":
    47.                     return "\u0075";
    48.  
    49.                 case "o":
    50.                     return "\u006F";
    51.  
    52.                 case "p":
    53.                     return "\u0064";
    54.  
    55.                 case "q":
    56.                     return "\u0062";
    57.  
    58.                 case "r":
    59.                     return "\u0279";
    60.  
    61.                 case "s":
    62.                     return "\u0073";
    63.  
    64.                 case "t":
    65.                     return "\u0287";
    66.  
    67.                 case "u":
    68.                     return "\u006E";
    69.  
    70.                 case "v":
    71.                     return "\u028C";
    72.  
    73.                 case "w":
    74.                     return "\u028D";
    75.  
    76.                 case "x":
    77.                     return "\u0078";
    78.  
    79.                 case "y":
    80.                     return "\u028E";
    81.  
    82.                 case "z":
    83.                     return "\u007A";
    84.  
    85.             }
    86.             return Ch.ToString();
    87.         }
    88.  
    89.         private void FormatString()
    90.         {
    91.             string replace = "";
    92.  
    93.  
    94.             foreach (char Ch in TB_Up.Text)
    95.             {
    96.                 replace += flip(Ch);
    97.             }
    98.  
    99.             string holding = "";
    100.             foreach (char Chx in replace)
    101.             {
    102.  
    103.                 holding = Chx + holding;
    104.             }
    105.             replace = holding;
    106.             TB_Down.Clear();
    107.             TB_Down.Text = replace;
    108.         }
    109.         private void TB_Up_KeyUp(object sender, KeyEventArgs e)
    110.         {
    111.             FormatString();  
    112.         }
    113.     }
    114. }


    as always if you see somewhere that needs improvement.

    C# Code:
    1. }
    2.  
    3. }    
    4.  
    5. }        
    6.  
    7.   ;)(ƃuıɹʇsʇɐɯɹoɟ            
    8.  
    9. {        
    10.  
    11. )ǝ sƃɹɐʇuǝʌǝʎǝʞ ,ɹǝpuǝs ʇɔǝɾqo(dnʎǝʞ_dn_qʇ pıoʌ ǝʇɐʌıɹd        
    12.  
    13. }        
    14.  
    15. ;ǝɔɐldǝɹ = ʇxǝʇ.uʍop_qʇ            
    16.  
    17. ;)(ɹɐǝlɔ.uʍop_qʇ            
    18.  
    19. ;ƃuıploɥ = ǝɔɐldǝɹ            
    20.  
    21. }            
    22.  
    23. ;ƃuıploɥ + xɥɔ = ƃuıploɥ                
    24.  
    25.  
    26. {            
    27.  
    28. )ǝɔɐldǝɹ uı xɥɔ ɹɐɥɔ( ɥɔɐǝɹoɟ            
    29.  
    30. ;"" = ƃuıploɥ ƃuıɹʇs            
    31.  
    32.  
    33. }            
    34.  
    35. ;)ɥɔ(dılɟ =+ ǝɔɐldǝɹ                
    36.  
    37. {            
    38.  
    39. )ʇxǝʇ.dn_qʇ uı ɥɔ ɹɐɥɔ( ɥɔɐǝɹoɟ            
    40.  
    41.  
    42.  
    43. ;"" = ǝɔɐldǝɹ ƃuıɹʇs            
    44.  
    45. {        
    46.  
    47. )(ƃuıɹʇsʇɐɯɹoɟ pıoʌ ǝʇɐʌıɹd        
    48.  
    49.  
    50. }        
    51.  
    52. ;)(ƃuıɹʇsoʇ.ɥɔ uɹnʇǝɹ            
    53.  
    54. }            
    55.  
    56.  
    57. ;"ɐ700n\" uɹnʇǝɹ                    
    58.  
    59. :"z" ǝsɐɔ                
    60.  
    61.  
    62. ;"ǝ820n\" uɹnʇǝɹ                    
    63.  
    64. :"ʎ" ǝsɐɔ                
    65.  
    66.  
    67. ;"8700n\" uɹnʇǝɹ                    
    68.  
    69. :"x" ǝsɐɔ                
    70.  
    71.  
    72. ;"p820n\" uɹnʇǝɹ                    
    73.  
    74. :"ʍ" ǝsɐɔ                
    75.  
    76.  
    77. ;"ɔ820n\" uɹnʇǝɹ                    
    78.  
    79. :"ʌ" ǝsɐɔ                
    80.  
    81.  
    82. ;"ǝ600n\" uɹnʇǝɹ                    
    83.  
    84. :"n" ǝsɐɔ                
    85.  
    86.  
    87. ;"7820n\" uɹnʇǝɹ                    
    88.  
    89. :"ʇ" ǝsɐɔ                
    90.  
    91.  
    92. ;"3700n\" uɹnʇǝɹ                    
    93.  
    94. :"s" ǝsɐɔ                
    95.  
    96.  
    97. ;"9720n\" uɹnʇǝɹ                    
    98.  
    99. :"ɹ" ǝsɐɔ                
    100.  
    101.  
    102. ;"2600n\" uɹnʇǝɹ                    
    103.  
    104. :"b" ǝsɐɔ                
    105.  
    106.  
    107. ;"4600n\" uɹnʇǝɹ                    
    108.  
    109. :"d" ǝsɐɔ                
    110.  
    111.  
    112. ;"ɟ600n\" uɹnʇǝɹ                    
    113.  
    114. :"o" ǝsɐɔ                
    115.  
    116.  
    117. ;"5700n\" uɹnʇǝɹ                    
    118.  
    119. :"u" ǝsɐɔ                
    120.  
    121.  
    122. ;"ɟ620n\" uɹnʇǝɹ                    
    123.  
    124. :"ɯ" ǝsɐɔ                
    125.  
    126.  
    127. ;"ɔ600n\" uɹnʇǝɹ                    
    128.  
    129. :"l" ǝsɐɔ                
    130.  
    131.  
    132. ;"ǝ920n\" uɹnʇǝɹ                    
    133.  
    134. :"ʞ" ǝsɐɔ                
    135.  
    136.  
    137. ;"ǝ720n\" uɹnʇǝɹ                    
    138.  
    139. :"ɾ" ǝsɐɔ                
    140.  
    141.  
    142. ;"1310n\" uɹnʇǝɹ                    
    143.  
    144. :"ı" ǝsɐɔ                
    145.  
    146.  
    147. ;"5620n\" uɹnʇǝɹ                    
    148.  
    149. :"ɥ" ǝsɐɔ                
    150.  
    151.  
    152. ;"3810n\" uɹnʇǝɹ                    
    153.  
    154. :"ƃ" ǝsɐɔ                
    155.  
    156.  
    157. ;"ɟ520n\" uɹnʇǝɹ                    
    158.  
    159. :"ɟ" ǝsɐɔ                
    160.  
    161.  
    162. ;"pp10n\" uɹnʇǝɹ                    
    163.  
    164. :"ǝ" ǝsɐɔ                
    165.  
    166.                    
    167.  
    168. ;"0700n\" uɹnʇǝɹ                    
    169.  
    170. :"p" ǝsɐɔ                
    171.  
    172.                
    173.  
    174. ;"4520n\" uɹnʇǝɹ                    
    175.  
    176. :"ɔ" ǝsɐɔ                
    177.  
    178.                    
    179.  
    180. ;"1700n\" uɹnʇǝɹ                    
    181.  
    182. :"q" ǝsɐɔ                
    183.  
    184.                    
    185.  
    186. ;"0520n\" uɹnʇǝɹ                    
    187.  
    188. :"ɐ" ǝsɐɔ                
    189.  
    190. {            
    191.  
    192. ))(ɹǝʍoloʇ.ʇs( ɥɔʇıʍs            
    193.  
    194.  
    195. ;)(ƃuıɹʇsoʇ.ɥɔ = ʇs ƃuıɹʇs            
    196.  
    197. {        
    198.  
    199. )ɥɔ ɹɐɥɔ(dılɟ ƃuıɹʇs ǝʇɐʌıɹd
    Personally I would use straight chars that way your switch isn't a string comparision for each one.

    c# Code:
    1. private static char flip(char Ch)
    2.         {
    3.             if (Ch >= 'A' && Ch <= 'Z')
    4.                 Ch = (char)(Ch + 0x20);
    5.             switch (Ch)
    6.             {
    7.                 case 'a':
    8.                     return '\u0250';
    9.  
    10.                 case 'b':
    11.                     return '\u0071';
    12.  
    13.                 case 'c':
    14.                     return '\u0254';
    15.  
    16.                 case 'd':
    17.                     return '\u0070';
    18.  
    19.                 case 'e':
    20.                     return '\u01DD';
    21.  
    22.                 case 'f':
    23.                     return '\u025F';
    24.  
    25.                 case 'g':
    26.                     return '\u0183';
    27.  
    28.                 case 'h':
    29.                     return '\u0265';
    30.  
    31.                 case 'i':
    32.                     return '\u0131';
    33.  
    34.                 case 'j':
    35.                     return '\u027E';
    36.  
    37.                 case 'k':
    38.                     return '\u029E';
    39.  
    40.                 case 'l':
    41.                     return '\u006C';
    42.  
    43.                 case 'm':
    44.                     return '\u026F';
    45.  
    46.                 case 'n':
    47.                     return '\u0075';
    48.  
    49.                 case 'o':
    50.                     return '\u006F';
    51.  
    52.                 case 'p':
    53.                     return '\u0064';
    54.  
    55.                 case 'q':
    56.                     return '\u0062';
    57.  
    58.                 case 'r':
    59.                     return '\u0279';
    60.  
    61.                 case 's':
    62.                     return '\u0073';
    63.  
    64.                 case 't':
    65.                     return '\u0287';
    66.  
    67.                 case 'u':
    68.                     return '\u006E';
    69.  
    70.                 case 'v':
    71.                     return '\u028C';
    72.  
    73.                 case 'w':
    74.                     return '\u028D';
    75.  
    76.                 case 'x':
    77.                     return '\u0078';
    78.  
    79.                 case 'y':
    80.                     return '\u028E';
    81.  
    82.                 case 'z':
    83.                     return '\u007A';
    84.  
    85.             }
    86.             return Ch;
    87.         }

  3. #3

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: Text Flip

    I was thinking of doing some sort of dictionary lookup as well

    im not sure which would be most efficient

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width