decoding html?

Discussion in 'HTML & Website Design' started by sdsvtdriver, Jun 4, 2006.

  1. #1
    Howdy all

    Is there a program that can decode this type of html (Escape codes?)?

    "%3Cdiv%20style%3D%22"

    which gets interpreted at <div style =.....

    Dreamweaver sees it as a hunk of text. I know this isn't human generated, or someone has a lot of time on their hands. :)
     
    sdsvtdriver, Jun 4, 2006 IP
  2. Travis

    Travis Peon

    Messages:
    539
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That normally comes if you copy text from a website, and put it directly into the "View" tab...and not the HTML/Source tabs (well it does for front page at least). Be sure to copy and paste it into Notepad or another plain text editor before doing so as to not have any nasty text formatting suprises.
     
    Travis, Jun 4, 2006 IP
  3. sdsvtdriver

    sdsvtdriver Peon

    Messages:
    70
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Notepad didn't interpret it, neither did Wordpad.
     
    sdsvtdriver, Jun 4, 2006 IP
  4. Amsterdam

    Amsterdam Well-Known Member

    Messages:
    361
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Last time I saw stuff like that it was encoded that way deliberately as a way of protecting a page's source. There is software that converts plain HTML to code like that - unfortunately, I can't remember what it is called or where I saw it.

    T
     
    Amsterdam, Jun 5, 2006 IP
  5. brian394

    brian394 Well-Known Member

    Messages:
    226
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    108
    #5
    Try this...

    Demo: http://home.earthlink.net/~duhomax/javascript_unescape.html

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
      <title>HTML &amp; Javascript Escape/Un-Escape Tool</title>
      <style type="text/css">
       form { margin: 0px; }
       textarea { width: 100%; height: 85px; margin-bottom: 10px; }
       div#decode_text_container { width: 40%; position: absolute; top: 10px; left: 1%; }
       div#encode_text_container { width: 40%; position: absolute; top: 10px; left: 46%; }
       div#seperator { width: 1px; height: 240px; background-color: black; position: absolute; left: 43%; top: 10px; }
       input.button { position: absolute; right: 5px; }
       h1 { margin: 0px; padding: 0px; margin-bottom: 5px; font-size: 16pt; font-family: Verdana, Arial, Sans-Serif; }
       body { font: 10pt verdana, arial, sans-serif; }
      </style>
      <script type="text/javascript">
      <!--
       function escape_text(input_str) {
        var i,j,one_char='',output_str='',all_characters='',all_hex_values='',one_hex_value='';
        for(i=0; i<256; i++) {
         one_hex_value = i.toString(16); // base 16 (hex)
         if (one_hex_value.length < 2) { one_hex_value = '0' + one_hex_value; }
         all_hex_values = all_hex_values + one_hex_value;
         all_characters = all_characters + unescape('%' + one_hex_value);
        }
        all_hex_values = all_hex_values.toUpperCase();
        input_str.replace(String.fromCharCode(13),"%13");
        for(j=0; j<input_str.length; j++){
         one_char = input_str.substr(j,1);
         for (i=0; i<all_characters.length; i++) {
          if (one_char == all_characters.substr(i,1)) { one_char = one_char.replace(one_char, '%' + all_hex_values.substr(i*2,2)); break; }
         }
         output_str = output_str + one_char;
        }
        return output_str;
       }
       function unescape_text(input_str) { return unescape(input_str); }
       function escape_text_onclick() { if (document.getElementById) { document.getElementById('t2').value = escape_text(document.getElementById('t1').value); } }
       function unescape_text_onclick() { if (document.getElementById) { document.getElementById('t4').value = unescape_text(document.getElementById('t3').value); } }
      //-->
      </script>
     </head>
     <body>
      <form action="" onsubmit="return false">
       <div id="decode_text_container">
        <h1>Un-Escape Text</h1>
        <textarea id="t3" rows="40" cols="10">%61%62%63</textarea><br />
        <textarea id="t4" rows="40" cols="10" readonly="readonly"></textarea><br />
        <input type="button" class="button" id="unescape_text_button" value="Un-Escape Text" onclick="unescape_text_onclick()" />
       </div>
       <div id="seperator"></div>
       <div id="encode_text_container">
        <h1>Escape Text</h1>
        <textarea id="t1" rows="40" cols="10">abc</textarea><br />
        <textarea id="t2" rows="40" cols="10" readonly="readonly"></textarea><br />
        <input type="button" class="button" id="escape_text_button" value="Escape Text" onclick="escape_text_onclick()" />
       </div>
      </form>
     </body>
    </html>
    
    Code (markup):
     
    brian394, Jun 5, 2006 IP