error C2022: '65279' : too big for character
-
Hi all, I am getting an error C2022: '65279' : too big for character at the line in bold below, What should I change here? This code works if I use wsprintfW and wszBuffer is WCHAR however I need this for multibyte and must use "_T" not "L" Any advise? Thanks, Jayjay
if( pRegInfo->uTaskRegID == 0 )
{
GUID AppGUID, TaskGUID;
::CoCreateGuid(&AppGUID);
::CoCreateGuid(&TaskGUID);
WCHAR wszGUID[50], wszTaskGUID[50];
::StringFromGUID2(AppGUID, wszGUID, 50);
::StringFromGUID2(TaskGUID, wszTaskGUID, 50);
TCHAR wszBuffer[1025] = { 0 };
::wsprintf(wszBuffer,
_T("\xfeff<?xml version=\"1.0\" encoding=\"UTF-16\" ?>\n")
_T("<applications xmlns=\"http://schemas.microsoft.com/windows/cpltasks/v1\\" xmlns:sh=\"http://schemas.microsoft.com/windows/tasks/v1\\">")
_T("<application id=\"%s\">")
_T("<sh:task id=\"%s\" needsElevation=\"%s\">")
#ifdef _UNICODE
L"sh:name@%s,-%ld</sh:name>"
L"sh:keywords@%s,-%ld</sh:keywords>"
L"sh:command%%systemroot%%\\system32\\control.exe /name %s</sh:command>"
#else
_T("sh:name@%hs,-%ld</sh:name>")
_T("sh:keywords@%hs,-%ld</sh:keywords>")
_T("sh:command%%systemroot%%\\system32\\control.exe /name %hs</sh:command>")
#endif // _UNICODE
_T("</sh:task>")
_T("<category id=\"%ld\">")
_T("<sh:task idref=\"%s\"/>")
_T("</category>")
_T("</application>")
_T("</applications>"),
wszGUID,
wszTaskGUID,
pRegInfo->dwRunLevel == 0 ? _T("false") : _T("true"),
szDllName, Info.uTaskRes,
szDllName, Info.uKeywordsRes,
Info.pstrCanonicalName,
pRegInfo->dwCategory,
wszTaskGUID);
::wsprintf(szGUID, _T("%ws"), wszGUID);
::lstrcpy(szTaskFileUrl, szDllFile);
::wsprintf(_FindLastOf(szTaskFileUrl, '.'), _T("_cpl%d.xml"), pRegInfo->iIndex + 1);
if( bRegister ) {
HANDLE hFile = ::CreateFile(szTaskFileUrl, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if( -
Hi all, I am getting an error C2022: '65279' : too big for character at the line in bold below, What should I change here? This code works if I use wsprintfW and wszBuffer is WCHAR however I need this for multibyte and must use "_T" not "L" Any advise? Thanks, Jayjay
if( pRegInfo->uTaskRegID == 0 )
{
GUID AppGUID, TaskGUID;
::CoCreateGuid(&AppGUID);
::CoCreateGuid(&TaskGUID);
WCHAR wszGUID[50], wszTaskGUID[50];
::StringFromGUID2(AppGUID, wszGUID, 50);
::StringFromGUID2(TaskGUID, wszTaskGUID, 50);
TCHAR wszBuffer[1025] = { 0 };
::wsprintf(wszBuffer,
_T("\xfeff<?xml version=\"1.0\" encoding=\"UTF-16\" ?>\n")
_T("<applications xmlns=\"http://schemas.microsoft.com/windows/cpltasks/v1\\" xmlns:sh=\"http://schemas.microsoft.com/windows/tasks/v1\\">")
_T("<application id=\"%s\">")
_T("<sh:task id=\"%s\" needsElevation=\"%s\">")
#ifdef _UNICODE
L"sh:name@%s,-%ld</sh:name>"
L"sh:keywords@%s,-%ld</sh:keywords>"
L"sh:command%%systemroot%%\\system32\\control.exe /name %s</sh:command>"
#else
_T("sh:name@%hs,-%ld</sh:name>")
_T("sh:keywords@%hs,-%ld</sh:keywords>")
_T("sh:command%%systemroot%%\\system32\\control.exe /name %hs</sh:command>")
#endif // _UNICODE
_T("</sh:task>")
_T("<category id=\"%ld\">")
_T("<sh:task idref=\"%s\"/>")
_T("</category>")
_T("</application>")
_T("</applications>"),
wszGUID,
wszTaskGUID,
pRegInfo->dwRunLevel == 0 ? _T("false") : _T("true"),
szDllName, Info.uTaskRes,
szDllName, Info.uKeywordsRes,
Info.pstrCanonicalName,
pRegInfo->dwCategory,
wszTaskGUID);
::wsprintf(szGUID, _T("%ws"), wszGUID);
::lstrcpy(szTaskFileUrl, szDllFile);
::wsprintf(_FindLastOf(szTaskFileUrl, '.'), _T("_cpl%d.xml"), pRegInfo->iIndex + 1);
if( bRegister ) {
HANDLE hFile = ::CreateFile(szTaskFileUrl, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(I don't see a bold line. Error C2022 in the documentation says, "The octal number following a backslash (\) in a character or string constant is too big to represent a character". So I am guess that you are trying to assign a number greater than 255 for a char variable. -Saurabh
-
I don't see a bold line. Error C2022 in the documentation says, "The octal number following a backslash (\) in a character or string constant is too big to represent a character". So I am guess that you are trying to assign a number greater than 255 for a char variable. -Saurabh
Hi Saurabh, It is this line
_T("\xfeff<?xml version=\"1.0\" encoding=\"UTF-16\" ?>\n")
Thanks, Jayjay
-
Hi Saurabh, It is this line
_T("\xfeff<?xml version=\"1.0\" encoding=\"UTF-16\" ?>\n")
Thanks, Jayjay
The first character is \xfeff which is 65279. This value cannot be stored in a char variable. I think you can split it into two characters for ANSI chars (\xfe\xff) and single char for wide-chars. -Saurabh
-
The first character is \xfeff which is 65279. This value cannot be stored in a char variable. I think you can split it into two characters for ANSI chars (\xfe\xff) and single char for wide-chars. -Saurabh
Saurabh.Garg wrote:
The first character is \xfeff which is 65279. This value cannot be stored in a char variable. I think you can split it into two characters for ANSI chars (\xfe\xff) and single char for wide-chars.
But: Keep in mind how values are stored.On an Intel Machine: \xfeff should be reversed when broken up as: \xff\xfe. :)
Bram van Kampen