Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 584771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:55:58+00:00 2026-05-13T14:55:58+00:00

I am having a very weird issue in the way strings get stored in

  • 0

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.

Here’s an overview of what I am doing:

Platform: C#/ASP.NET MVC 1.0, SQL Server 2005, SparkViewEngine, YUI 2

In my view, I serialize an object into a JSON data structure using Json.NET from NewtonSoft.

<script type="text/javascript">
    // <![CDATA[ 
    var data = YAHOO.lang.JSON.parse("${Newtonsoft.Json.JsonConvert.Serialize(Model)}");
    ....
</script>

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.

The database field is an NVARCHAR(2000).

For some of the entries, I get these weird characters in the string when I copy and paste from the database to notepad.

Compile ?Analysis ?& ?Recommendations? deck

In Firebug, it shows as a bunch of line breaks:

Analysis & Recommendations deck”,”StartDate”:”1/19/10″,”FinishDate”:”1/26/10″,”Duration”:6.0,”

Compile 
Analysis 
& 
Recommendations
 deck

UPDATE
After talking to the user, I discovered that they were using the copying and pasting from a word document onto the HTML form.

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.

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:55:58+00:00Added an answer on May 13, 2026 at 2:55 pm

    This appears to be a case of you not handling the quote characters properly. You have several ways to go. The way I use for comments for our web site is to make sure all quotes are encoded, both single and double, so that both your SQL, ASPX & Javascript won’t hiccup.
    Our method is for customer comment fields so we’re overboard on the conversions.

    Function SafeComment(ByVal strInput)
    ' Renders Any Comment Codes Harmless And Leaves Them HTML readable In An eMail Or Web Page
    ' Try: SafeComment("`~!@#$%^&*()_+=-{}][|\'"";:<>?/.,")
        SafeComment = ""
        If Len(strInput) = 0 Then Exit Function
        SafeComment =   Replace(Replace(Replace( _
                        Replace(Replace(Replace( _
                        Replace(Replace(Replace( _
                        Replace(Replace(Replace( _
                            Server.HtmlEncode(Trim(strInput)), _
                        "-", "&#45;"), ":", "&#58;"), "|", "&#124;"), _
                        "`", "&#96;"), "(", "&#40;"), ")", "&#41;"), _
                        "%", "&#37;"), "^", "&#94;"), """", "&#34;"), _
                        "/", "&#47;"), "*", "&#42;"), "'", "&#39;")
    End Function
    

    It’s not pretty, but it does the job.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a very weird issue with templates. Getting an error error: ‘traits’
I'm having a very weird issue with the command line and running Ant. I
I'm having a very weird issue in IE6. If I set a div container
I'm getting a very weird issue with standard ASP.NET backend code, and the latest
I am having a very weird problem with building a SQL Server 2008 Database
Im having a very weird issue. I have a normal ajax call that upload
I'm working with jQuery's .get() function and I'm having a very weird problem using
I'm having a weird issue with Visual Studio 2008. Every time I fire it
I'm currently having a really weird issue and I can't seem to figure out
I am having a very large string, and when I read it in Java,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.