title: How to create a javascript string in razor
body: <p>I have seen some posts regarding this topic and a few blogs, but none seem to mention the output I'm getting.</p>
  
  <p>What I want is to generate a google maps map with information on it. Manually entering the information results in the correct information. So that part works.</p>
  
  <p>Where I'm getting stuck is when I'm going to dynamiccaly create the javascript array with the string with the information I want on my map.</p>
  
  <p>The html code I want to get is:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;     
      var projects = [
           ['Kantoor 4.1 bestaande bouw', 52.25446, 6.16024700000003, 'Deventer', '', 'adviseurs', 'rating30'],
           ['School nieuw 4.0', 52.243161, 4.43677860000003, 'Noordwijk', '', 'adviseurs', 'rating30'],   
      ];
  </code></pre>
  
  <p>Very simple javascript array, which I thought to create with:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var projects = [
      @foreach (var item in Model)
      {
          @HttpUtility.JavaScriptStringEncode("['" + item.Gebouwnaam + "', " + item.LocatieLatitude.ToString().Replace(",", ".") + ", " + item.LocatieLongitude.ToString().Replace(",", ".") + ", '" + item.Plaats + "', '" + item.Gebruiksfunctie + "', '" + item.Licentiehouder + "', '" + item.rating + "'],");
       }
  ];
  &lt;/script&gt;
  </code></pre>
  
  <p>However this gives me:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var projects = [
      [\u0027Kantoor 4.1 bestaande bouw\u0027, 52.25446, 6.16024700000003, \u0027Deventer\u0027, \u0027\u0027, \u0027adviseurs\u0027, \u0027rating30\u0027],
      [\u0027School nieuw 4.0\u0027, 52.243161, 4.43677860000003, \u0027Noordwijk\u0027, \u0027\u0027, \u0027adviseurs\u0027, \u0027rating30\u0027],
  ];  
  &lt;/script&gt;
  </code></pre>
  
  <p>Escaping the single quotes doesn't work.
  What am I doing wrong?</p>