Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Client Scripting
Expertise: Beginner
Feb 4, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Trouble With String That Contains a Backslash

I get a string from the Microsoft Index Server like this: "Information \uber". If I try to assign this string to a variable I get a runtime error: "Invalid character."
var str = "<%String see above%>
I think the problem is that there's only one backslash in this string, and so JavaScript assumes that it is an escape sequence, but \u is not a valid escape sequence. Is there a way to convert this string, so that it includes two backslashes? I'm using Windows NT 4.0 and Internet Explorer 4.01.

You're right. The backslash character (\) has a special meaning in JavaScript. Dealing with a string constant (like the one you're getting from Microsoft Index Server) that includes a single backslash is awfully problematic. Your best bet would probably be to try to somehow convince Index Server to add a second backslash to the string rather than trying to solve the problem through JavaScript.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date