title: Does javascript force specific charset?
body: <p>I am trying to use javascript, without framework(prototype, jQuery,etc), to insert data passed from a html form to an mysql database. I have managed to get this working but, get a problem with some special characters commonly used in my language(æøå). utf-8 supports these characters, and everything works fine when I skip the javascript. However when I try to pass the content of the html form through javascript post function and executing the query with my working php script, every æøå is converted into Ã¦Ã¸Ã¥.</p>
  
  <p>To break it down, does javascript somehow force a specific charset when no other is determined in the code? I have tried to specify charset in the header of the javascript post and the php file as well as the html form.</p>
  
  <p>I believe it must be something wrong or missing in my javascript file, formpost.js:</p>
  
  <pre><code>    function sendText(visbool){
    var http =new GetXmlHttpObject();
    var url = "sendtext.php";
    var ovrskrift = document.form1.overskrift.value;
    var cont = document.form1.content.value;
  
    var params = "overskrift=" + ovrskrift + "&amp;tekst=" + cont + "&amp;visbool=" + visbool;
    http.open("POST", url, true);
  
    //Send the proper header information along with the request
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.setRequestHeader("Content-length", params.length);
    http.setRequestHeader("Connection", "close");
  
    http.onreadystatechange = function() {//Call a function when the state changes.
      if(http.readyState == 4 &amp;&amp; http.status == 200) {
          // gjør noe smart her
      }
    }
    http.send(params);
  }
  
  
  function GetXmlHttpObject()
   { 
   var objXMLHttp=null;
   if (window.XMLHttpRequest)
    {
    objXMLHttp=new XMLHttpRequest();
    }
   else if (window.ActiveXObject)
    {
    objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
   return objXMLHttp;
   }
  </code></pre>
  
  <p>sendtext.php:</p>
  
  <pre><code>&lt;?php
  //variabler for spørring
  $date= date('Y-m-d');
  $overskrift= $_POST["overskrift"];
  $ostr='36';
  $tekst= $_POST["content"];
  //$tekst="test tekst";
  $istr='32';
  $bilde="";
  $style="onlyinfo.css";
  //$vis=$_POST['visbool'];
  $vis=0;
  
  require ('../config.php'); // henter informasjon om database tilkoblingen fra config.php
  
  if (!$con){die('Could not connect: ' . mysql_error());} // lager feilmelding hvis tilkoblingen mislyktes
  
  // spørring for databasen, konstrueres etter variablene som er angitt ovenfor
  $sql="INSERT INTO tbl_info(dato,overskrift_tekst,overskrift_str,infotekst_tekst,infotekst_str,bilde,style,vismeg) VALUES('" . $date . "','" . $overskrift . "','" . $ostr . "','" . $tekst . "','" . $istr . "','" . $bilde . "','" . $style . "','" . $vis . "')";
  $result = mysql_query($sql); // kjører spørring og lagrer resultat i $result
  
  mysql_close($con); // lukker database tilkoblingen
  ?&gt;
  </code></pre>
  
  <p>createslide.php: (reserved .php extension for future code implementation)</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"&gt;
  &lt;head&gt;
  &lt;title&gt;inforMe: Legg til side&lt;/title&gt;
  &lt;link type="text/css" rel="stylesheet" href="./css/style.css" id="adminss"&gt;  
  &lt;script src="./js/formpost.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="./tinymce/jscripts/tiny_mce/tiny_mce.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  tinyMCE.init({
      mode : "textareas"
  });
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div class="imgupload"&gt;
    &lt;input type="button" value="Last opp bilde"&gt; &lt;img src="" /&gt;
  &lt;/div&gt;
  &lt;div class="form"&gt;
    &lt;form name="form1" method="post" action="sendtext.php"&gt;
      &lt;label for="overskrift"&gt;Overskrift:&lt;/label&gt;
      &lt;input type="text" size="70" id="overskift" name="overskrift"&gt;&lt;br /&gt;
      &lt;label for="content"&gt;Tekst:&lt;/label&gt;
      &lt;textarea id="content" name="content" cols="50" rows="15"&gt;This is some content that will be editable with TinyMCE.&lt;/textarea&gt;
      &lt;input type="button" value="save draft" onclick="sendText(0)"/&gt;
      &lt;input type="button" value="save and publish" onclick="sendText(1)"/&gt;
      &lt;input type="submit" value="regular submit button"/&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>NB!</strong>
  I don't really know where to put this information so.. well.. I decided to go with it here:
  First of all thanks for all good suggestions below. I belive the question were answered. As to my problem, it is only partly solved.</p>
  
  <p>It seems like the utf-8 charset is lost somewhere along the line here, if I create a new mysql database with Latin-1 charset and change the charset options in my files to iso-8859-1 it works exactly right. Since my test setup is based on all norwegian software(browsers, db server, etc), I suppose wherever it is not otherwise specified it will return iso-8859-1</p>
  
  <p><strong>NBB!</strong>
  And now it's all good again. everything works fine when I add:</p>
  
  <p>header('Content-Type: text/plain; charset=utf-8');</p>
  
  <p>to the top of my sendtext.php file.</p>