Author Topic: _T("xxxx") Error  (Read 174 times)

rrvt

  • New Community Member
  • Posts: 2
  • Hero Points: 0
_T("xxxx") Error
« on: September 27, 2019, 07:46:46 pm »
I am using the v24 beta.  I am moving some of my code from Ansi characters to Unicode (yuk).  In the process of doing that I need to add _T(...) around literal strings so that the code can be compiled with just 8 bit characters and with 16 bit characters.  The problem comes when I add _T( to and existing string.  Here is what happens:
  • The string is "abc"
  • Adding _T( at beginning of string yields:
  • _T(")abc"

Notice where the automatic right parenthesis winds up (inside the string literal!).  When I add the closing right parenthesis after the c" the compiler is fine with the result but the code then doesn't produce what I want...

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2811
  • Hero Points: 425
Re: _T("xxxx") Error
« Reply #1 on: September 27, 2019, 10:56:38 pm »
I am having trouble reproducing this problem.  This looks like the sort of thing that would be very dependent on your configuration.  Could you post your user.cfg.xml (from your SlickEdit configuration directory).  A few more questions:

1) Is _T() defined in your project?
2) What is your exact sequence of keystrokes?
3) Does auto-complete come up, or any other code help dialogs (such as function argument help)?
4) I assume you are encountering this in C or C++ language mode?

jporkkahtc

  • Senior Community Member
  • Posts: 1837
  • Hero Points: 178
  • Text
Re: _T("xxxx") Error
« Reply #2 on: September 27, 2019, 11:40:19 pm »
Besides the weird issue, you can do this with a search & replace.
Search for
Code: [Select]
"([^"\r\n]*)"Replace with
Code: [Select]
_T($1)Using Perl RegEx

Works well, unless you have embedded quotes in a string.

You can also just prefix with L, as in L"This is a wide string".
You will never go back to ascii, so there is little point to using the _T() macro.