Author |
Topic |
|
znakeeye
Tomato Guru
379 Posts |
Posted - Jul 18 2007 : 01:56:35 AM
|
I've been missing this functionality since I discovered the unicode in VS.
Basically, if _INC_TCHAR is defined, all strings sent to functions should be surrounded with _T() if the type of the input parameter is a TCHAR. I'm not sure if you take types into consideration when completing members, but please consider the following example.
void foo(LPCTSTR szFoo) {}
void bar(CString s) {}
void baz(TCHAR *psz) {}
foo("test"); --> foo(_T("test"));
bar("test"); --> bar(_T("test"));
baz("test"); --> baz(_T("test"));
That work becomes even more tedious if _TEXT() is the preferred macro style. _T(), _TEXT() and TEXT() all do the same thing.
What do you think? |
|
feline
Whole Tomato Software
United Kingdom
19022 Posts |
Posted - Jul 18 2007 : 07:01:14 AM
|
For now the best solution is autotext. You should already have the autotext entry:
_T($selected$)$end$
so select the string and then trigger "Insert Autotext". There should be a toolbar button for this, or you can assign a keyboard shortcut to this.
You can also access this via VA's shift + right click menu.
If you have selected text then the first list of autotext entries only shows you items that work on selected text, so they contain $selected$.
VA will list the items in the order they are shown in the edit autotext dialog, so you can make sure the one you want is at the top of the list by dragging and dropping the items in the edit autotext dialog tree. |
zen is the art of being at one with the two'ness |
|
|
znakeeye
Tomato Guru
379 Posts |
Posted - Jul 20 2007 : 02:50:01 AM
|
Ah, cool. Thanks =) |
|
|
lucwens
New Member
9 Posts |
Posted - Jan 19 2016 : 10:48:49 AM
|
Hi,
at this moment, when I want to convert an ANSI string to Unicode, I set my cursor somewhere in the string and then type Alt+Shift+] to select the string including the ", and next I take Ctrl+RMB to go to the context menu, then Surround with (VA)->_T(...).
Is there any way that I can make this faster : just put my cursor inside the string and next type some keyboard combination that then expands the selection to the string including the " and perform the _T(...) surrounding?
Would be a nice feature for anyone, like me, who has to convert an mbcs application to unicode.
|
|
|
feline
Whole Tomato Software
United Kingdom
19022 Posts |
Posted - Jan 19 2016 : 2:22:21 PM
|
You could try a find and replace regular expression. Search for ", then not ", then a second ", and do the surround in the replace.
The following works in VS2013, but you would need to be careful since it also matches #include lines.
Find = ("[^"]*") Replace = _T($1) |
zen is the art of being at one with the two'ness |
|
|
sean
Whole Tomato Software
USA
2817 Posts |
Posted - Jan 19 2016 : 3:19:45 PM
|
Rather than use the context menu, you could assign a Surround With character to your _T snippet. see Access via Surrounding Character at http://docs.wholetomato.com/default.asp?W257
If you went that route, you probably would want to change the registry value of "SurroundWithSnippetOnCharIgnoreWhitespace" -- from 00 to 01 -- so that the Surround With character is honored on selections without whitespace (by default, snippets accessed via the Surround With character are only executed if the selection contains whitespace). |
|
|
|
Topic |
|