LPWSTR wbuff = &*str.begin();
if (codepage == CP_ACP || IsValidCodePage(codepage))
{
- int n = MultiByteToWideChar(codepage, flags, lpd, len, wbuff, wlen - 1);
+ int n = MultiByteToWideChar(codepage, flags, lpd, static_cast<int>(len), wbuff, static_cast<int>(wlen - 1));
if (n)
{
/*
{
if (GetLastError() == ERROR_INVALID_FLAGS)
{
- int n = MultiByteToWideChar(codepage, 0, lpd, len, wbuff, wlen-1);
+ int n = MultiByteToWideChar(codepage, 0, lpd, static_cast<int>(len), wbuff, static_cast<int>(wlen-1));
if (n)
{
/* NB: MultiByteToWideChar is documented as only zero-terminating
*lossy = true;
flags = 0;
// wlen & wbuff are still fine
- n = MultiByteToWideChar(codepage, flags, lpd, len, wbuff, wlen-1);
+ n = MultiByteToWideChar(codepage, flags, lpd, static_cast<int>(len), wbuff, static_cast<int>(wlen-1));
if (n)
{
try
if (cpin == CP_UCS2LE)
{
if (srclen == -1)
- srclen = wcslen((wchar_t *)src) * sizeof(wchar_t);
+ srclen = static_cast<unsigned>(wcslen((wchar_t *)src) * sizeof(wchar_t));
memcpy(wbuff.get(), src, srclen);
n = srclen / sizeof(wchar_t);
}
else if (cpin == CP_UCS2BE)
{
if (srclen == -1)
- srclen = wcslen((wchar_t *)src) * sizeof(wchar_t);
+ srclen = static_cast<unsigned>(wcslen((wchar_t *)src) * sizeof(wchar_t));
_swab((char *)src, (char *)wbuff.get(), srclen);
n = srclen / sizeof(wchar_t);
}
if (destcp == CP_ACP || IsValidCodePage(destcp))
{
DWORD flags = 0;
- int bytes = WideCharToMultiByte(destcp, flags, (LPCWSTR)src, srcbytes/2, 0, 0, NULL, NULL);
+ int bytes = WideCharToMultiByte(destcp, flags, (LPCWSTR)src, static_cast<int>(srcbytes/2), 0, 0, NULL, NULL);
dest->resize(bytes + 2);
int losses = 0;
- bytes = WideCharToMultiByte(destcp, flags, (LPCWSTR)src, srcbytes/2, (char *)dest->ptr, dest->capacity, NULL, NULL);
+ bytes = WideCharToMultiByte(destcp, flags, (LPCWSTR)src, static_cast<int>(srcbytes/2), (char *)dest->ptr, static_cast<int>(dest->capacity), NULL, NULL);
dest->ptr[bytes] = 0;
dest->ptr[bytes+1] = 0;
dest->size = bytes;
if (srccp == CP_ACP || IsValidCodePage(srccp))
{
DWORD flags = 0;
- int wchars = MultiByteToWideChar(srccp, flags, (LPCSTR)src, srcbytes, 0, 0);
+ int wchars = MultiByteToWideChar(srccp, flags, (LPCSTR)src, static_cast<int>(srcbytes), 0, 0);
dest->resize((wchars + 1) *2);
- wchars = MultiByteToWideChar(srccp, flags, (LPCSTR)src, srcbytes, (LPWSTR)dest->ptr, dest->capacity/2);
+ wchars = MultiByteToWideChar(srccp, flags, (LPCSTR)src, static_cast<int>(srcbytes), (LPWSTR)dest->ptr, static_cast<int>(dest->capacity/2));
dest->ptr[wchars * 2] = 0;
dest->ptr[wchars * 2 + 1] = 0;
dest->size = wchars * 2;
*/
static void convert(const std::wstring& from, unsigned codepage, std::string& to)
{
- int len = WideCharToMultiByte(codepage, 0, from.c_str(), from.length(), 0, 0, 0, 0);
+ int len = WideCharToMultiByte(codepage, 0, from.c_str(), static_cast<int>(from.length()), 0, 0, 0, 0);
if (len)
{
to.resize(len);
- WideCharToMultiByte(codepage, 0, from.c_str(), from.length(), &to[0], len, NULL, NULL);
+ WideCharToMultiByte(codepage, 0, from.c_str(), static_cast<int>(from.length()), &to[0], static_cast<int>(len), NULL, NULL);
}
else
{
while (succeed && GetWordFromFile(hfile, buffer, nBufferSize, charset))
{
- if (!WriteFile(tfile, buffer, _tcslen(buffer), &numwritten, NULL))
+ if (!WriteFile(tfile, buffer, lstrlen(buffer), &numwritten, NULL))
succeed = false;
if (bVCPROJ)
{
m_strVssProjectBase = string_makelower(m_strVssProjectBase);
//take out last '\\'
- int nLen = m_strVssProjectBase.size();
+ size_t nLen = m_strVssProjectBase.size();
if (paths::EndsWithSlash(m_strVssProjectBase))
m_strVssProjectBase.resize(nLen - 1);
String strSearch = m_strVssProjectBase.c_str() + 2; // Don't compare first 2
- int index = strSavePath.find(strSearch); //Search for project base path
- if (index > -1)
+ size_t index = strSavePath.find(strSearch); //Search for project base path
+ if (index != String::npos)
{
index++;
m_strVssProjectFull = savepath.c_str() + index + strSearch.length();
//nab the equals sign
if (!GetWordFromFile(hFile, buffer, sizeof(buffer)/sizeof(buffer[0]), _T("=")))
return false;
- if (!WriteFile(tFile, buffer, _tcslen(buffer),
+ if (!WriteFile(tFile, buffer, lstrlen(buffer),
&dwNumWritten, NULL))
return false;
String stemp = _T("\""") + m_strVssProjectFull +
_T(""");
- if (!WriteFile(tFile, stemp.c_str(), stemp.size(),
+ if (!WriteFile(tFile, stemp.c_str(), static_cast<DWORD>(stemp.size()),
&dwNumWritten, NULL))
return false;
if (!WriteFile(tFile, _T("\""), 1, &dwNumWritten, NULL))
return false;
}
- if (!WriteFile(tFile, buffer, _tcslen(buffer), &dwNumWritten, NULL))
+ if (!WriteFile(tFile, buffer, lstrlen(buffer), &dwNumWritten, NULL))
return false;
return true;
//nab until next no space, and no =
if (!GetWordFromFile(hFile, buffer, sizeof(buffer)/sizeof(buffer[0]), _T(" =")))
return false;
- if (!WriteFile(tFile, buffer, _tcslen(buffer), &dwNumWritten, NULL))
+ if (!WriteFile(tFile, buffer, lstrlen(buffer), &dwNumWritten, NULL))
return false;
//nab word
if (!GetWordFromFile(hFile, buffer, sizeof(buffer)/sizeof(buffer[0]), _T("\\\n.")))
if (buffer[0] != '\\')
_tcsncat(buf, buffer, _tcslen(buffer));
- if (!WriteFile(tFile, buffer, _tcslen(buffer), &dwNumWritten, NULL))
+ if (!WriteFile(tFile, buffer, lstrlen(buffer), &dwNumWritten, NULL))
return false;
if (!GetWordFromFile(hFile, buffer, sizeof(buffer)/sizeof(buffer[0]), _T("\\\n.")))
return false;
}
- if (!WriteFile(tFile, buffer, _tcslen(buffer), &dwNumWritten, NULL))
+ if (!WriteFile(tFile, buffer, lstrlen(buffer), &dwNumWritten, NULL))
return false;
return true;
//nab until the no space, and no =
if (!GetWordFromFile(hFile, buffer, sizeof(buffer)/sizeof(buffer[0]), _T(" =")))
return false;
- if (!WriteFile(tFile, buffer, _tcslen(buffer), &dwNumWritten, NULL))
+ if (!WriteFile(tFile, buffer, lstrlen(buffer), &dwNumWritten, NULL))
return false;
String stemp = _T("\\u0022") + m_strVssProjectFull + capp + _T("\\u0022");
- if (!WriteFile(tFile, stemp.c_str(), stemp.size(),
+ if (!WriteFile(tFile, stemp.c_str(), static_cast<DWORD>(stemp.size()),
&dwNumWritten, NULL))
return false;