Results 1 to 15 of 15

Thread: [RESOLVED] Local html form (without php) encoding problem

  1. #1

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Resolved [RESOLVED] Local html form (without php) encoding problem

    Hi Guys !

    AutoCAD has the ability to create a board within the application.

    The board that I created is hosted locally (z:\plans\board\ ...) and not on the web. I can do the form but it gets harder at sending the form, special characters appear in place of accents.

    Im using Firefox 4.0 on Windows XP Pro and Office 2007...

    Does anyone can help me ?

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    	<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
    	<title>Test</title>
    </head>
    <body
    	style="color: rgb(255, 255, 255); background-color: rgb(153, 0, 0);"
    	alink="#000099" link="#000099" vlink="#990099">
    <form enctype="text/plain" method="post" action="mailto:email@internet.com" name="MyForm"><input name="txtName" value="Pr&#233;nom Nom"><br>
    	<br>
    	<input type="submit" value="Envoyer la demande...">
    </form>
    </body>
    </html>
    Link of printscreen result:



    Thanks in advance !
    Last edited by DubweiserTM; May 26th, 2011 at 10:37 AM.
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Local html form (without php) encoding problem

    Try changing this line:
    Code:
    <meta content="text/html; charset=UTF-8" http-equiv="content-type">

  3. #3

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Local html form (without php) encoding problem

    I tried your solution, with the another bad result...



    Another suggestion ?

    Thanks in advance !
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  4. #4
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Local html form (without php) encoding problem

    That (what appears in the browser) means that your page isn't really saved as UTF-8. You could change it, but I've tried it for myself and that still doesn't fix what appears in Outlook (other email clients are working just fine though... surprise surprise). I haven't found anything that actually works for Outlook yet...

  5. #5

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Local html form (without php) encoding problem

    Quote Originally Posted by SambaNeko View Post
    That (what appears in the browser) means that your page isn't really saved as UTF-8. You could change it...
    I do it with notepad and I can't save it with a specific type...

    Maybe someone have already experienced this problem ??? Help !

    Thanks in advance !
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  6. #6
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Local html form (without php) encoding problem

    you could try getting rid of the enctype attribute in your form. I'm not sure if that'd help or not.
    Like Archer? Check out some Sterling Archer quotes.

  7. #7

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Local html form (without php) encoding problem

    Quote Originally Posted by kows View Post
    you could try getting rid of the enctype attribute in your form. I'm not sure if that'd help or not.
    Same resultat...

    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  8. #8
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Local html form (without php) encoding problem

    Also when I try your code with IE9, the email body is empty (the form field data is not there). IE9 being new, I'm not familiar with all of its inevitable failings yet - can anyone replicate and confirm this one?

  9. #9
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Local html form (without php) encoding problem

    since no one else has asked about it... I will... I don't think it's your HTML form... you can make all the changes you want to it... unless Outlook supports unicode it isn't going to make a hill of beans what you do with the HTML form...

    The attached screenshot shows what I got on the back end after running the SAME code that was in post #1... all I did was to re-route the To address...

    -tg
    Attached Images Attached Images  
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Local html form (without php) encoding problem

    Yeah, it seems like Outlook hates Unicode and favors ISO, whereas all other email clients are the opposite.

    With the form, I changed the meta charset back to ISO and found one working result, but only in IE9 (I don't have any other IE versions to test with, and it doesn't work in Firefox). I've taken and cobbled some script from this page, and came up with this mess:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    	<meta content="text/html;charset=ISO-8859-1" http-equiv="content-type">
    	<title>Test</title>
    </head>
    <body>
    <form id="myForm" enctype="text/plain" method="post" action="mailto:email@internet.com" name="MyForm">
    <input name="txtName" value="Pr&#233;nom Nom"><br>
    	<br>
    	<input type="submit" value="Envoyer la demande...">
    </form>
    
    <script>
    window.onload = function(){
      document.getElementById('myForm').onsubmit = function(){
        var mailBody = '';
        var inputs = this.getElementsByTagName('input');
        for(var j=0;j<inputs.length;j++){
          mailBody += inputs[j].name + '=' + changeIt(inputs[j].value) + ',';
        }
        this.action += '?body='+mailBody;
      };
    };
    
    var hexVals = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                  "A", "B", "C", "D", "E", "F");
    var unsafeString = "\"<>&#37;\\^[]`\+\$\,";
    
    function isUnsafe(compareChar){
      if (unsafeString.indexOf(compareChar) == -1 && compareChar.charCodeAt(0) > 32
          && compareChar.charCodeAt(0) < 123){
            return false;
      }else{
        return true;
      }
    }
    
    function decToHex(num, radix){
      var hexString = "";
      while (num >= radix){
       temp = num % radix;
       num = Math.floor(num / radix);
       hexString += hexVals[temp];
      }
      hexString += hexVals[num];
      return reversal(hexString);
    }
    
    function reversal(s){
      var len = s.length;
      var trans = "";
      for (k=0; k<len; k++){
        trans = trans + s.substring(len-k-1, len-k);
      }
      s = trans;
      return s;
    }
    
    function convert(val){
      return  "%" + decToHex(val.charCodeAt(0), 16);
    }
    
    function changeIt(val){
      var len     = val.length;
      var newStr  = "";
      var original = val;
      for (i=0;i<len;i++){
            if (val.substring(i,i+1).charCodeAt(0) < 255){
                if (isUnsafe(val.substring(i,i+1)) == false){ 
                  newStr += val.substring(i,i+1);
                }else{
                  newStr += convert(val.substring(i,i+1));
                }
            }else{
                 alert ("Found a non-ISO-8859-1 character at position: " + (i+1) + ",\nPlease eliminate before continuing.");
                 newStr = original; i=len;               
            }
          }
    
      return newStr;
    }
    
    </script>
    </body>
    </html>
    As said, I've only seen this work with IE9. Firefox won't seem to accept a ?body argument in the mailto, when the mailto is used as a form action. Whereas IE9 seems to ignore all form fields when the form action is a mailto, but it will still accept ?body. Ugh.

    Well, maybe there's something useful in there... or not.
    Last edited by SambaNeko; May 27th, 2011 at 01:40 PM.

  11. #11

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Local html form (without php) encoding problem

    Quote Originally Posted by techgnome View Post
    since no one else has asked about it... I will... I don't think it's your HTML form... you can make all the changes you want to it... unless Outlook supports unicode it isn't going to make a hill of beans what you do with the HTML form...

    The attached screenshot shows what I got on the back end after running the SAME code that was in post #1... all I did was to re-route the To address...

    -tg
    Im not sure If I understand when you talk about "re-route the To address" ???

    As per your printscreen (...from Windows Internet Explorer), is this works also in Firefox ?

    Thanks !

    Quote Originally Posted by SambaNeko View Post
    Yeah, it seems like Outlook hates Unicode and favors ISO, whereas all other email clients are the opposite.

    With the form, I changed the meta charset back to ISO and found one working result, but only in IE9 (I don't have any other IE versions to test with, and it doesn't work in Firefox). I've taken and cobbled some script from this page, and came up with this mess:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    	<meta content="text/html;charset=ISO-8859-1" http-equiv="content-type">
    	<title>Test</title>
    </head>
    <body>
    <form id="myForm" enctype="text/plain" method="post" action="mailto:email@internet.com" name="MyForm">
    <input name="txtName" value="Prénom Nom"><br>
    	<br>
    	<input type="submit" value="Envoyer la demande...">
    </form>
    
    <script>
    window.onload = function(){
      document.getElementById('myForm').onsubmit = function(){
        var mailBody = '';
        var inputs = this.getElementsByTagName('input');
        for(var j=0;j<inputs.length;j++){
          mailBody += inputs[j].name + '=' + changeIt(inputs[j].value) + ',';
        }
        this.action += '?body='+mailBody;
      };
    };
    
    var hexVals = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
                  "A", "B", "C", "D", "E", "F");
    var unsafeString = "\"<>%\\^[]`\+\$\,";
    
    function isUnsafe(compareChar){
      if (unsafeString.indexOf(compareChar) == -1 && compareChar.charCodeAt(0) > 32
          && compareChar.charCodeAt(0) < 123){
            return false;
      }else{
        return true;
      }
    }
    
    function decToHex(num, radix){
      var hexString = "";
      while (num >= radix){
       temp = num % radix;
       num = Math.floor(num / radix);
       hexString += hexVals[temp];
      }
      hexString += hexVals[num];
      return reversal(hexString);
    }
    
    function reversal(s){
      var len = s.length;
      var trans = "";
      for (k=0; k<len; k++){
        trans = trans + s.substring(len-k-1, len-k);
      }
      s = trans;
      return s;
    }
    
    function convert(val){
      return  "%" + decToHex(val.charCodeAt(0), 16);
    }
    
    function changeIt(val){
      var len     = val.length;
      var newStr  = "";
      var original = val;
      for (i=0;i<len;i++){
            if (val.substring(i,i+1).charCodeAt(0) < 255){
                if (isUnsafe(val.substring(i,i+1)) == false){ 
                  newStr += val.substring(i,i+1);
                }else{
                  newStr += convert(val.substring(i,i+1));
                }
            }else{
                 alert ("Found a non-ISO-8859-1 character at position: " + (i+1) + ",\nPlease eliminate before continuing.");
                 newStr = original; i=len;               
            }
          }
    
      return newStr;
    }
    
    </script>
    </body>
    </html>
    As said, I've only seen this work with IE9. Firefox won't seem to accept a ?body argument in the mailto, when the mailto is used as a form action. Whereas IE9 seems to ignore all form fields when the form action is a mailto, but it will still accept ?body. Ugh.

    Well, maybe there's something useful in there... or not.
    Thanks for your help, I appreciate very much, but I prefer to use Firefox...
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  12. #12
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Local html form (without php) encoding problem

    Not sure if you need to write the functions for use with fire fox like so or not.
    HTML Code:
    <script>
    function Somefunction(objForm) {
    
    }
    </script>
    
    <form name="form" action="" method="post" onsubmit="return Somefunction(this);">
    
    </form>
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  13. #13

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Local html form (without php) encoding problem

    I tried your suggestion (Code below), I dont know if there are mistake, but nothing happen when I click on the button...

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    
    <script>
    function Somefunction(objForm) {
    
    }
    </script>
    
    
    <head>
    	<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
    	<title>Test1.html</title>
    </head>
    <body
    	style="color: rgb(255, 255, 255); background-color: rgb(153, 0, 0);"
    	alink="#000099" link="#000099" vlink="#990099">
    
    	<form name="MyForm" action="" method="post" onsubmit="return Somefunction(this);">
    		<input name="txtName" value="Prénom Nom">
    		<br>
    		<input type="submit" value="Envoyer la demande...">
    	</form>
    
    </body>
    </html>
    Thanks !
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  14. #14
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: Local html form (without php) encoding problem

    No, what Nightwalker83 posted is not relevant (and no, Firefox does not need an inline onsubmit attribute for the function to work).

    As techgnome said, this probably doesn't have much to do with the HTML, but with Outlook's ability to support unicode (what techgnome presumably meant by "re-route the To address" was that he sent the email to himself, and opened it with a mail client that properly supports unicode). You can do some Googling to investigate if your Outlook is properly configured for unicode.

  15. #15

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Local html form (without php) encoding problem

    Hi, me again !

    I try all the code below on a Windows 7 computer, and that's okay, on my computer (Windows XP) it's still the same, but most of the users that will use this page are on Windows 7...

    Where logic ends, starts the computing...
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    
    <html>
    
    <head>
    	<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
    	<title>Test</title>
    </head>
    
    <body
    	style="color: rgb(255, 255, 255); background-color: rgb(153, 0, 0);"
    	alink="#000099" link="#000099" vlink="#990099">
    	<form enctype="text/plain" method="post" action="mailto:email@internet.com" name="MyForm">
    		<input name="txtName" value="Pr&#233;nom Nom"><br>
    		<br>
    		<input type="submit" value="Envoyer la demande...">
    	</form>
    </body>
    
    </html>
    Thanks to you all for your precious time !
    Attached Images Attached Images  
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

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