Search code examples
c++ccharactersequencesalternate

What's the alternate character combination for the double quote character in C/C++?


I've not had the Kernighan and Ritchie C reference in years, but I remember that there was a page in there that talked about how to enter characters that were unavailable to you. (WAY back in the day, some keyboards lacked characters like ", ~, etc.)

To be clear, let me give an example. I'm not looking for a way to get quotes in strings, but rather, I want to replace this:

printf("foo");

with this:

printf([alternate sequence]foo[alternate sequence]);

For the curious, I have an automated process that involves generating C/C++ code, but the (closed source) commercial tool involved strips quotes in its data streams and the documentation is quite clear on the fact that they do not provide a way to escape them.

EDIT:

Wow, I hadn't expected such a heavy response. This might merit a little more detail on my process. I'm doing automated build systems, which means that I live with certain restrictions when it comes to changing the code I'm compiling. For now, we have to live with the assumption that I have to get a string, spaces and all, into a preprocessor definiton. I already went down the 'PreprocessorDefinition' road. This left me with my usual fallback: Define the string in the operating environment and have the project file set the definition from there:

Preprocessor Definitions     WIN32;_DEBUG;THINGIE=$(THINGIE)

The hope was that I could get around MSVC's stripping of quotes in anything handed to the build with /D using a trigraph, by doing something like this in my build automation script:

ENV['THINGIE'] = "??''Yodeling Monkey Nuggets??''"
run_msbuild_command

I guess it's time for a plan C.


Solution

  • You are looking for a trigraph for " character? I don't think one exists.

    Trigraphs don't exist for all characters. Only a few characters have trigraph sequences.