Note that there are some explanatory texts on larger screens.

plurals
  1. POString Encoding Issue
    primarykey
    data
    text
    <p>I am having a very weird issue in the way strings get stored in my database, and as a result, I am getting these "unterminated string literal" errors in Javascript.</p> <p>Here's an overview of what I am doing:</p> <p>Platform: C#/ASP.NET MVC 1.0, SQL Server 2005, SparkViewEngine, YUI 2</p> <p>In my view, I serialize an object into a JSON data structure using Json.NET from NewtonSoft.</p> <pre><code>&lt;script type="text/javascript"&gt; // &lt;![CDATA[ var data = YAHOO.lang.JSON.parse("${Newtonsoft.Json.JsonConvert.Serialize(Model)}"); .... &lt;/script&gt; </code></pre> <p>Normally, this works, but I noticed that one of the fields I pull from the database contains the following data, which causes the string to not be formed properly.</p> <p>The database field is an <strong>NVARCHAR(2000)</strong>.</p> <p>For some of the entries, I get these weird characters in the string when I copy and paste from the database to notepad.</p> <p><strong>Compile ?Analysis ?&amp; ?Recommendations? deck</strong></p> <p>In Firebug, it shows as a bunch of line breaks:</p> <p>Analysis &amp; Recommendations deck","StartDate":"1/19/10","FinishDate":"1/26/10","Duration":6.0,"</p> <p><strong>Compile 
Analysis 
&amp; 
Recommendations
 deck</strong></p> <p><strong>UPDATE</strong> After talking to the user, I discovered that they were using the copying and pasting from a word document onto the HTML form.</p> <p>The form itself uses the YUI Connection Manager to make an asynchronous POST call (AJAX) to save the form values. The database saved the form field value along with any encoding associated with it.</p> <p>It seems like there are characters in Word that are printable, but not in ASCII. Is there any way to detect this and encode correctly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload