Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Quotes in a string

Posted on 2009-05-08
2
Medium Priority
?
396 Views
Last Modified: 2013-12-17
When a printer name is passed to Adobe it needs to quotes around it if the string contains blanks.  This two line program shows that in order to get the desired quote mystery slashs are inserted.  I have tried similar things with char[] with no better results.
char ch = '"';
string test = ch + "my string" + ch;
 
Expected result is "my string", actual result is "\my string\".

Open in new window

0
Comment
Question by:wilfordrocks
2 Comments
 
LVL 7

Accepted Solution

by:
alexpercsi earned 2000 total points
ID: 24336817
This is strange.

Generally when I need to insert quotes in a string I just prefix them with the \ character which is the escape operator. It does not show up in the final string.
Try this and tell me how it works out.
string test = "\"my string\"";

Open in new window

0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 24337121
let me guess ... you determined that it was \"mystring\" by using the debugger? most likely putting your mouse over the variable?

The debugger shows you strings in escaped format...


Greg
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Loops Section Overview

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question