My ANSI was stronger that yours (wchar_t pointer powered VS String-ISH) – Microsoft Q&A
I presently create an VSIX and I need to update my Dictionary. Unfortunately, I’m using IWizard thru a C++ CLR Managed project that force me to use system::string. Then, I begin to code
String^ StrGuid = replacementsDictionary["$guid1$"];
String^ Final;
/*** ?????? ***********/
replacementsDictionary->Add("$EXPANDGUID$", Final);
and after some moment, I realize that I really stuck on the code, seeking on web for answer. Does I’m too old and I’m loosing skill??? Then I decide to start a Console Application just to see. And POW! Into 2 line, one to convert and the other to uppercase the result.
wchar_t StrGuid[256] = "{3b8fc1ba-428e-4131-9aca-dd016730492e}";
wchar_t Final[266];
swprintf_s(Final, L"{ 0x%.8s, 0x%.4s, 0x%.4s, {0x%.2s, 0x%.2s, 0x%.2s, 0x%.2s, 0x%.2s, 0x%.2s, 0x%.2s, 0x%.2s}};", StrGuid + 1, StrGuid + 10, StrGuid + 15, StrGuid + 20, StrGuid + 22, StrGuid + 25, StrGuid + 27, StrGuid + 29, StrGuid + 31, StrGuid + 33, StrGuid + 35);
_wcsupr_s(Final);
wprintf(L"extern \"C\" __declspec(selectany) const _GUID CLSID_$projectname$ = %s\n", Final);
/*** wprintf Output ***/
extern "C" __declspec(selectany) const _GUID CLSID_$projectname$ = { 0X3B8FC1BA, 0X428E, 0X4131, {0X9A, 0XCA, 0XDD, 0X01, 0X67, 0X30, 0X49, 0X2E}};
Now. I know I can do it into a complex way, but which trick we case use with String? String Format seem to be obsolete.
who to achieve this kind of thing with System:String in one straight line??? Can we use str pointer offset inside a string format?
Or if you prefer. What is the equivalent %.2s in String:Format?
Thanks!