本文整理汇总了C++中AString::Len方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::Len方法的具体用法?C++ AString::Len怎么用?C++ AString::Len使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::Len方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SevenZipGetDefaultPassword
DWORD WINAPI SevenZipGetDefaultPassword(HARC _harc, LPSTR _szPassword, DWORD _dwSize)
{
g_StdOut.SetLastError(0);
LPCWSTR lpPassword;
if (_harc == NULL)
lpPassword = g_StdOut.GetDefaultPassword();
else
{
COpenArchive* pOpenArchive = COpenArchive::FindObject(_harc);
if (pOpenArchive == NULL)
{
g_StdOut.SetLastError(ERROR_HARC_ISNOT_OPENED);
return -1;
}
lpPassword = pOpenArchive->GetDefaultPassword();
}
if (lpPassword == NULL)
{
g_StdOut.SetLastError(ERROR_PASSWORD_FILE);
return -1;
}
AString strPassword;
if (g_StdOut.GetUnicodeMode())
::ConvertUnicodeToUTF8(lpPassword, strPassword);
else
strPassword = ::GetOemString(lpPassword);
if ((DWORD)strPassword.Len() >= _dwSize)
{
g_StdOut.SetLastError(ERROR_INVALID_VALUE);
return strPassword.Len() + 1;
}
::lstrcpyn(_szPassword, strPassword, _dwSize);
return 0;
}
示例2: FindExt
static bool FindExt(const char *p, const FString &name)
{
int dotPos = name.ReverseFind_Dot();
if (dotPos < 0 || dotPos == (int)name.Len() - 1)
return false;
AString s;
for (unsigned pos = dotPos + 1;; pos++)
{
wchar_t c = name[pos];
if (c == 0)
break;
if (c >= 0x80)
return false;
s += (char)MyCharLower_Ascii((char)c);
}
for (unsigned i = 0; p[i] != 0;)
{
unsigned j;
for (j = i; p[j] != ' '; j++);
if (s.Len() == j - i && memcmp(p + i, (const char *)s, s.Len()) == 0)
return true;
i = j + 1;
}
return false;
}
示例3: CopyStrLimited
static void CopyStrLimited(char *dest, const AString &src, unsigned len)
{
len--;
if (src.Len() < len)
len = src.Len();
memcpy(dest, src, sizeof(dest[0]) * len);
dest[len] = 0;
}
示例4: test_AString
static void test_AString()
{
AString a;
a = "abc";
assert(MyStringCompare(&a[0],"abc") == 0);
assert(a.Len() == 3);
a = GetAnsiString(L"abc");
assert(MyStringCompare(&a[0],"abc") == 0);
assert(a.Len() == 3);
}
示例5: MultiByteToUnicodeString2
void MultiByteToUnicodeString2(UString &dest, const AString &src, UINT /* codePage */)
{
dest.Empty();
if (src.IsEmpty())
return;
size_t limit = ((size_t)src.Len() + 1) * 2;
wchar_t *d = dest.GetBuf((unsigned)limit);
size_t len = mbstowcs(d, src, limit);
if (len != (size_t)-1)
{
dest.ReleaseBuf_SetEnd((unsigned)len);
return;
}
{
unsigned i;
const char *s = (const char *)src;
for (i = 0;;)
{
Byte c = (Byte)s[i];
if (c == 0)
break;
d[i++] = (wchar_t)c;
}
d[i] = 0;
dest.ReleaseBuf_SetLen(i);
}
}
示例6: HasTailSlash
bool HasTailSlash(const AString &name, UINT
#if defined(_WIN32) && !defined(UNDER_CE)
codePage
#endif
)
{
if (name.IsEmpty())
return false;
LPCSTR prev =
#if defined(_WIN32) && !defined(UNDER_CE)
CharPrevExA((WORD)codePage, name, &name[name.Len()], 0);
#else
(LPCSTR)(name) + (name.Len() - 1);
#endif
return (*prev == '/');
}
示例7: SaveComments
bool CFSFolder::SaveComments()
{
AString utf;
{
UString unicode;
_comments.SaveToString(unicode);
ConvertUnicodeToUTF8(unicode, utf);
}
if (!utf.IsAscii())
utf.Insert(0, "\xEF\xBB\xBF" "\r\n");
FString path = _path + kDescriptionFileName;
// We must set same attrib. COutFile::CreateAlways can fail, if file has another attrib.
DWORD attrib = FILE_ATTRIBUTE_NORMAL;
{
CFileInfo fi;
if (fi.Find(path))
attrib = fi.Attrib;
}
NIO::COutFile file;
if (!file.CreateAlways(path, attrib))
return false;
UInt32 processed;
file.Write(utf, utf.Len(), processed);
_commentsAreLoaded = false;
return true;
}
示例8: MultiByteToUnicodeString
UString MultiByteToUnicodeString(const AString &srcString, UINT codePage)
{
if (!srcString.IsEmpty())
{
UString resultString;
const char * path = &srcString[0];
CFStringRef cfpath = CFStringCreateWithCString(NULL,path,kCFStringEncodingUTF8);
if (cfpath)
{
CFMutableStringRef cfpath2 = CFStringCreateMutableCopy(NULL,0,cfpath);
CFRelease(cfpath);
CFStringNormalize(cfpath2,kCFStringNormalizationFormC);
size_t n = CFStringGetLength(cfpath2);
for(size_t i = 0 ; i< n ;i++) {
UniChar uc = CFStringGetCharacterAtIndex(cfpath2,i);
resultString += (wchar_t)uc; // FIXME
}
CFRelease(cfpath2);
return resultString;
}
}
UString resultString;
for (int i = 0; i < srcString.Len(); i++)
resultString += wchar_t(srcString[i] & 255);
return resultString;
}
示例9: WaitNextLine
static bool WaitNextLine(const AString &s, unsigned &pos)
{
for (; pos < s.Len(); pos++)
if (s[pos] == 0x0A)
return true;
return false;
}
示例10: GetTextConfig
bool GetTextConfig(const AString &s, CObjectVector<CTextConfigPair> &pairs)
{
pairs.Clear();
unsigned pos = 0;
/////////////////////
// read strings
for (;;)
{
if (!SkipSpaces(s, pos))
break;
CTextConfigPair pair;
unsigned finishPos;
AString temp = GetIDString(((const char *)s) + pos, finishPos);
if (!ConvertUTF8ToUnicode(temp, pair.ID))
return false;
if (finishPos == 0)
return false;
pos += finishPos;
if (!SkipSpaces(s, pos))
return false;
if (s[pos] != '=')
return false;
pos++;
if (!SkipSpaces(s, pos))
return false;
if (s[pos] != '\"')
return false;
pos++;
AString message;
for (;;)
{
if (pos >= s.Len())
return false;
char c = s[pos++];
if (c == '\"')
break;
if (c == '\\')
{
c = s[pos++];
switch (c)
{
case 'n': message += '\n'; break;
case 't': message += '\t'; break;
case '\\': message += '\\'; break;
case '\"': message += '\"'; break;
default: message += '\\'; message += c; break;
}
}
else
message += c;
}
if (!ConvertUTF8ToUnicode(message, pair.String))
return false;
pairs.Add(pair);
}
return true;
}
示例11: testMaxOSX_stringConvert
void testMaxOSX_stringConvert()
{
/*
0xE8, // latin small letter e with grave
0xE9, // latin small letter e with acute
L'a',
0xE0, // latin small letter a with grave
0x20AC, // euro sign
*/
struct
{
char astr [256];
wchar_t ustr [256];
}
tab [] =
{
{
// 'a' , 'e with acute' , 'e with grave' , 'a with grave' , 'u with grave' , 'b' , '.' , 't' , 'x' , 't'
{ 0x61, 0x65, 0xcc, 0x81 , 0x65, 0xcc, 0x80, 0x61, 0xcc, 0x80, 0x75, 0xcc, 0x80, 0x62, 0x2e, 0x74, 0x78, 0x74, 0 },
{ 0x61, 0xe9, 0xe8, 0xe0, 0xf9, 0x62, 0x2e, 0x74, 0x78, 0x74, 0 }
},
{
// 'a' , 'euro sign' , 'b' , '.' , 't' , 'x' , 't' , '\n'
{ 0x61, 0xe2, 0x82, 0xac, 0x62, 0x2e, 0x74, 0x78, 0x74, 0x0a, 0 },
{ 0x61, 0x20AC, 0x62, 0x2e, 0x74, 0x78, 0x74, 0x0a, 0 }
},
{
{ 0 },
{ 0 }
}
};
int i;
printf("testMaxOSX_stringConvert : \n");
i = 0;
while (tab[i].astr[0])
{
printf(" %s\n",tab[i].astr);
UString ustr = GetUnicodeString(tab[i].astr);
// dumpWStr("1",&ustr[0]);
assert(MyStringCompare(&ustr[0],tab[i].ustr) == 0);
assert(ustr.Len() == wcslen(tab[i].ustr) );
AString astr = GetAnsiString(ustr);
assert(MyStringCompare(&astr[0],tab[i].astr) == 0);
assert(astr.Len() == strlen(tab[i].astr) );
i++;
}
}
示例12: DeleteItems
void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin))
{
CDisableTimerProcessing disableTimerProcessing(*this);
CRecordVector<UInt32> indices;
GetOperatedItemIndices(indices);
if (indices.IsEmpty())
return;
CSelectedState state;
SaveSelectedState(state);
#ifndef UNDER_CE
// WM6 / SHFileOperationW doesn't ask user! So we use internal delete
if (IsFSFolder() && toRecycleBin)
{
bool useInternalDelete = false;
#ifndef _UNICODE
if (!g_IsNT)
{
CDynamicBuffer<CHAR> buffer;
FOR_VECTOR (i, indices)
{
const AString path = GetSystemString(GetFsPath() + GetItemRelPath(indices[i]));
memcpy(buffer.GetCurPtrAndGrow(path.Len() + 1), (const CHAR *)path, (path.Len() + 1) * sizeof(CHAR));
}
*buffer.GetCurPtrAndGrow(1) = 0;
SHFILEOPSTRUCTA fo;
fo.hwnd = GetParent();
fo.wFunc = FO_DELETE;
fo.pFrom = (const CHAR *)buffer;
fo.pTo = 0;
fo.fFlags = 0;
if (toRecycleBin)
fo.fFlags |= FOF_ALLOWUNDO;
// fo.fFlags |= FOF_NOCONFIRMATION;
// fo.fFlags |= FOF_NOERRORUI;
// fo.fFlags |= FOF_SILENT;
// fo.fFlags |= FOF_WANTNUKEWARNING;
fo.fAnyOperationsAborted = FALSE;
fo.hNameMappings = 0;
fo.lpszProgressTitle = 0;
/* int res = */ ::SHFileOperationA(&fo);
}
示例13: ClipboardSetText
bool ClipboardSetText(HWND owner, const UString &s)
{
CClipboard clipboard;
if (!clipboard.Open(owner))
return false;
if (!::EmptyClipboard())
return false;
bool res;
res = ClipboardSetData(CF_UNICODETEXT, (const wchar_t *)s, (s.Len() + 1) * sizeof(wchar_t));
#ifndef _UNICODE
AString a = UnicodeStringToMultiByte(s, CP_ACP);
if (ClipboardSetData(CF_TEXT, (const char *)a, (a.Len() + 1) * sizeof(char)))
res = true;
a = UnicodeStringToMultiByte(s, CP_OEMCP);
if (ClipboardSetData(CF_OEMTEXT, (const char *)a, (a.Len() + 1) * sizeof(char)))
res = true;
#endif
return res;
}
示例14: HexToByte
static bool ParseSha1(const CXmlItem &item, const char *name, Byte *digest)
{
int index = item.FindSubTag(name);
if (index < 0)
return false;
const CXmlItem &checkItem = item.SubItems[index];
const AString style = checkItem.GetPropVal("style");
if (style == "SHA1")
{
const AString s = checkItem.GetSubString();
if (s.Len() != SHA1_DIGEST_SIZE * 2)
return false;
for (unsigned i = 0; i < s.Len(); i += 2)
{
int b0 = HexToByte(s[i]);
int b1 = HexToByte(s[i + 1]);
if (b0 < 0 || b1 < 0)
return false;
digest[i / 2] = (Byte)((b0 << 4) | b1);
}
return true;
}
return false;
}
示例15: SkipSpaces
static bool SkipSpaces(const AString &s, unsigned &pos)
{
for (; pos < s.Len(); pos++)
{
char c = s[pos];
if (!IsDelimitChar(c))
{
if (c != ';')
return true;
if (!WaitNextLine(s, pos))
return false;
}
}
return false;
}