3

I'm using Visual Studio 6 to debug a C++ application. The application is compiled for unicode string support. The CString type is used for manipulating strings. When I am using the debugger, the watch window will display the first character of the string, but will not display the full string. I tried using XDebug, but this tool does not handle unicode strings properly. As a work around, I can create a custom watch for each character of the string by indexing into the private array the CString maintains, but this is very tedious.

How can I view the full, unicode value of a CString in the VC6 debugger?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
JadeMason
  • 1,181
  • 1
  • 14
  • 23
  • TRACE, MessageBox, log file, although I've never had this problem in VS for unicode and CString. Try VS2005, VS2008 or VS2010? – AJG85 Sep 14 '11 at 16:06
  • VC6 is the required IDE, I am not able to upgrade. Dumping to a file/console/message box is undesired. I'd like to just use a watch and inspect with the normal debugging interface. – JadeMason Sep 14 '11 at 16:36
  • I don't have VC6 to test with but I would expect this to work as MFC objects like CString predate even VC6. – AJG85 Sep 14 '11 at 18:13

1 Answers1

7

Go to tools->options->Debug, and check the "Display unicode string" check-box. That would probably fix the problem. Two other options:

  1. In the watch window, if you have a Unicode string variable named szText, add it to the watch as szText,su. This will tell VS to interpret it as a Unicode string (See Symbols for Watch Variables for more of this sort).
  2. Worst comes to worst, you can have a global ANSI string buffer, and a global function that will get a Unicode CString and store its content as ANSI, in that global variable. Then, when need call that function with the string whose content you'd like to see in the watch window, and watch the ANSI buffer.

But the "Display unicode string" thing is probably the problem...

Eran
  • 21,632
  • 6
  • 56
  • 89