本文整理汇总了C++中CharToWide函数的典型用法代码示例。如果您正苦于以下问题:C++ CharToWide函数的具体用法?C++ CharToWide怎么用?C++ CharToWide使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CharToWide函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ArcCharToWide
// Convert archived names and comments to Unicode.
// Allows user to select a code page in GUI.
void ArcCharToWide(const char *Src,wchar *Dest,size_t DestSize,ACTW_ENCODING Encoding)
{
#if defined(_WIN_ALL) // Console Windows RAR.
if (Encoding==ACTW_UTF8)
UtfToWide(Src,Dest,DestSize);
else
{
Array<char> NameA;
if (Encoding==ACTW_OEM)
{
NameA.Alloc(DestSize+1);
IntToExt(Src,&NameA[0],NameA.Size());
Src=&NameA[0];
}
CharToWide(Src,Dest,DestSize);
}
#else // RAR for Unix.
if (Encoding==ACTW_UTF8)
UtfToWide(Src,Dest,DestSize);
else
CharToWide(Src,Dest,DestSize);
#endif
// Ensure that we return a zero terminate string for security reason.
// While [Jni]CharToWide might already do it, be protected in case of future
// changes in these functions.
if (DestSize>0)
Dest[DestSize-1]=0;
}
开发者ID:sina-ht,项目名称:enfle,代码行数:30,代码来源:strfn.cpp
示例2: TestIconv
static void TestIconv(const Stroka& utf8, const Stroka& other, ECharset enc) {
Wtroka wide0 = CharToWide(utf8, CODES_UTF8);
Wtroka wide1 = CharToWide(other, enc);
UNIT_ASSERT(wide0 == wide1);
Stroka temp = WideToChar(wide0, CODES_UTF8);
UNIT_ASSERT(temp == utf8);
temp = WideToChar(wide0, enc);
UNIT_ASSERT(temp == other);
temp = Recode(enc, CODES_UTF8, other);
UNIT_ASSERT(temp == utf8);
temp = Recode(CODES_UTF8, enc, utf8);
UNIT_ASSERT(temp == other);
size_t read = 0;
size_t written = 0;
RECODE_RESULT res = RecodeToUnicode(enc, other.c_str(), wide1.begin(), other.size(), wide1.size(), read, written);
UNIT_ASSERT(res == RECODE_OK);
UNIT_ASSERT(read == other.size());
UNIT_ASSERT(written == wide1.size());
UNIT_ASSERT(wide0 == wide1);
res = RecodeFromUnicode(enc, wide0.c_str(), temp.begin(), wide0.size(), temp.size(), read, written);
UNIT_ASSERT(res == RECODE_OK);
UNIT_ASSERT(read == wide0.size());
UNIT_ASSERT(written == other.size());
UNIT_ASSERT(temp == other);
}
开发者ID:Mirocow,项目名称:balancer,代码行数:33,代码来源:iconv_ut.cpp
示例3: ConvertNameToFull
void ConvertNameToFull(const wchar *Src,wchar *Dest)
{
if (Src==NULL || *Src==0)
{
*Dest=0;
return;
}
#ifdef _WIN_32
if (WinNT())
{
wchar FullName[NM],*NamePtr;
if (GetFullPathNameW(Src,sizeof(FullName)/sizeof(FullName[0]),FullName,&NamePtr))
strcpyw(Dest,FullName);
else
if (Src!=Dest)
strcpyw(Dest,Src);
}
else
{
char AnsiName[NM];
WideToChar(Src,AnsiName);
ConvertNameToFull(AnsiName,AnsiName);
CharToWide(AnsiName,Dest);
}
#else
char AnsiName[NM];
WideToChar(Src,AnsiName);
ConvertNameToFull(AnsiName,AnsiName);
CharToWide(AnsiName,Dest);
#endif
}
开发者ID:zachberger,项目名称:UnRarX,代码行数:31,代码来源:filefn.cpp
示例4: ToString
void CDocListRetrieverFromDisc::FillDocInfo(SDocumentAttribtes& attrs)
{
Stroka strFilePath = m_SmartFileFind.GetFoundFilePath(m_iCurPath);
Stroka strURL;
if (strFilePath == m_strSearchDir) {
TStringBuf left, right;
PathHelper::Split(strFilePath, left, right);
strURL = ToString(right);
} else
strURL = strFilePath.substr(m_strSearchDir.size());
if (strURL.empty())
ythrow yexception() << "Can't build url for file \"" << strFilePath
<< "\" with searchdir \"" << m_strSearchDir << "\".";
TransformBackSlash(strURL);
attrs.m_strUrl = strURL;
Stroka strTime;
if (stroka(m_strLTM) == "file") {
CTime lw_time = m_SmartFileFind.GetFoundFileInfo(m_iCurPath).m_LastWriteTime;
strTime = lw_time.Format("%d.%m.%Y %H:%M:%S");
}
if (strTime.empty())
strTime = m_strStartTime;
attrs.m_strTitle = CharToWide(strTime);
attrs.m_strSource = strURL;
attrs.m_strTitle = CharToWide(attrs.m_strSource); // ??? rewriting
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:33,代码来源:doclistretrieverfromdisc.cpp
示例5: return
int CommandData::IsProcessFile(FileHeader &NewLhd,bool *ExactMatch,int MatchType)
{
if (strlen(NewLhd.FileName)>=NM || wcslen(NewLhd.FileNameW)>=NM)
return(0);
bool Dir=(NewLhd.Flags & LHD_WINDOWMASK)==LHD_DIRECTORY;
if (ExclCheck(NewLhd.FileName,Dir,false,true))
return(0);
#ifndef SFX_MODULE
if (TimeCheck(NewLhd.mtime))
return(0);
if ((NewLhd.FileAttr & ExclFileAttr)!=0 || InclAttrSet && (NewLhd.FileAttr & InclFileAttr)==0)
return(0);
if (!Dir && SizeCheck(NewLhd.FullUnpSize))
return(0);
#endif
char *ArgName;
wchar *ArgNameW;
FileArgs->Rewind();
for (int StringCount=1;FileArgs->GetString(&ArgName,&ArgNameW);StringCount++)
{
#ifndef SFX_MODULE
bool Unicode=(NewLhd.Flags & LHD_UNICODE) || ArgNameW!=NULL && *ArgNameW!=0;
if (Unicode)
{
wchar NameW[NM],ArgW[NM],*NamePtr=NewLhd.FileNameW;
bool CorrectUnicode=true;
if (ArgNameW==NULL || *ArgNameW==0)
{
if (!CharToWide(ArgName,ArgW) || *ArgW==0)
CorrectUnicode=false;
ArgNameW=ArgW;
}
if ((NewLhd.Flags & LHD_UNICODE)==0)
{
if (!CharToWide(NewLhd.FileName,NameW) || *NameW==0)
CorrectUnicode=false;
NamePtr=NameW;
}
if (CmpName(ArgNameW,NamePtr,MatchType))
{
if (ExactMatch!=NULL)
*ExactMatch=wcsicompc(ArgNameW,NamePtr)==0;
return(StringCount);
}
if (CorrectUnicode)
continue;
}
#endif
if (CmpName(ArgName,NewLhd.FileName,MatchType))
{
if (ExactMatch!=NULL)
*ExactMatch=stricompc(ArgName,NewLhd.FileName)==0;
return(StringCount);
}
}
return(0);
}
开发者ID:DreamingPiggy,项目名称:xreader-hg,代码行数:57,代码来源:cmddata.cpp
示例6: return
int CommandData::IsProcessFile(FileHeader &NewLhd,bool *ExactMatch,int MatchType)
{
if (strlen(NewLhd.FileName)>=NM || strlenw(NewLhd.FileNameW)>=NM)
return(0);
if (ExclCheck(NewLhd.FileName,false))
return(0);
#ifndef SFX_MODULE
if (TimeCheck(NewLhd.mtime))
return(0);
#endif
char *ArgName;
wchar *ArgNameW;
FileArgs->Rewind();
for (int StringCount=1;FileArgs->GetString(&ArgName,&ArgNameW);StringCount++)
{
#ifndef SFX_MODULE
bool Unicode=(NewLhd.Flags & LHD_UNICODE) || ArgNameW!=NULL;
if (Unicode)
{
wchar NameW[NM],ArgW[NM],*NamePtr=NewLhd.FileNameW;
if (ArgNameW==NULL)
{
CharToWide(ArgName,ArgW);
ArgNameW=ArgW;
}
if ((NewLhd.Flags & LHD_UNICODE)==0)
{
CharToWide(NewLhd.FileName,NameW);
NamePtr=NameW;
}
if (CmpName(ArgNameW,NamePtr,MatchType))
{
if (ExactMatch!=NULL)
*ExactMatch=stricompcw(ArgNameW,NamePtr)==0;
return(StringCount);
}
continue;
}
#endif
if (CmpName(ArgName,NewLhd.FileName,MatchType))
{
if (ExactMatch!=NULL)
*ExactMatch=stricompc(ArgName,NewLhd.FileName)==0;
return(StringCount);
}
}
return(0);
}
开发者ID:ProfDrLuigi,项目名称:zanka,代码行数:48,代码来源:cmddata.cpp
示例7: MakeNameUsable
void MakeNameUsable(char *Name,bool Extended)
{
#ifdef _WIN_ALL
// In Windows we also need to convert characters not defined in current
// code page. This double conversion changes them to '?', which is
// catched by code below.
size_t NameLength=strlen(Name);
wchar NameW[NM];
CharToWide(Name,NameW,ASIZE(NameW));
WideToChar(NameW,Name,NameLength+1);
Name[NameLength]=0;
#endif
for (char *s=Name;*s!=0;s=charnext(s))
{
if (strchr(Extended ? "?*<>|\"":"?*",*s)!=NULL || Extended && (byte)*s<32)
*s='_';
#ifdef _EMX
if (*s=='=')
*s='_';
#endif
#ifndef _UNIX
if (s-Name>1 && *s==':')
*s='_';
// Remove ' ' and '.' before path separator, but allow .\ and ..\.
if ((*s==' ' || *s=='.' && s>Name && !IsPathDiv(s[-1]) && s[-1]!='.') && IsPathDiv(s[1]))
*s='_';
#endif
}
}
开发者ID:KyleSanderson,项目名称:mpc-hc,代码行数:29,代码来源:pathfn.cpp
示例8: getWord
bool CSentence::GetWSLemmaString(Wtroka& sLemmas, const CWordSequence& ws, bool bLem) const
{
sLemmas = ws.GetCapitalizedLemma();
if (bLem)
return !sLemmas.empty();
if (sLemmas.empty())
for (int j = ws.FirstWord(); j <= ws.LastWord(); j++) {
if (!sLemmas.empty())
sLemmas += ' ';
sLemmas += getWord(j)->GetOriginalText();
}
static const Wtroka trim_chars = CharToWide(" \"\'");
TWtringBuf res = sLemmas;
while (!res.empty() && trim_chars.find(res[0]) != TWtringBuf::npos)
res.Skip(1);
while (!res.empty() && trim_chars.find(res.back()) != TWtringBuf::npos)
res.Chop(1);
if (sLemmas.size() != res.size())
sLemmas = ::ToWtring(res);
return true;
}
开发者ID:dubrousky,项目名称:tomita-parser,代码行数:26,代码来源:sentence.cpp
示例9: strcpy
void FindFile::SetMask(const char *FindMask)
{
strcpy(FindFile::FindMask,FindMask);
if (*FindMaskW==0)
CharToWide(FindMask,FindMaskW);
FirstCall=true;
}
开发者ID:LubosD,项目名称:fatrat-unpack,代码行数:7,代码来源:find.cpp
示例10: AddError
bool TParserBase::RecodeToUtf8(Stroka& text)
{
if (Encoding == CODES_UNKNOWN) {
if (!IsStringASCII(~text, ~text + +text)) {
AddError(Substitute("Unknown encoding: \"$0\".", text));
return false;
}
} else if (Encoding == CODES_UTF8) {
if (!IsUtf(text)) {
AddError(Substitute("Invalid utf8: \"$0\".", text));
return false;
}
} else {
try {
CharToWide(text, RecodeBuffer, Encoding);
WideToUTF8(RecodeBuffer, text);
} catch (yexception&) {
AddError(Substitute("Cannot recode from $0 to utf8: \"$1\".", NameByCharset(Encoding), text));
return false;
}
}
return true;
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:26,代码来源:parserbase.cpp
示例11: return
bool FindFile::FastFind(const char *FindMask,const wchar *FindMaskW,struct FindData *fd,bool GetSymLink)
{
fd->Error=false;
#ifndef _UNIX
if (IsWildcard(FindMask,FindMaskW))
return(false);
#endif
#ifdef _WIN_32
HANDLE hFind=Win32Find(INVALID_HANDLE_VALUE,FindMask,FindMaskW,fd);
if (hFind==INVALID_HANDLE_VALUE)
return(false);
FindClose(hFind);
#else
struct stat st;
if (GetSymLink)
{
#ifdef SAVE_LINKS
if (lstat(FindMask,&st)!=0)
#else
if (stat(FindMask,&st)!=0)
#endif
{
fd->Error=(errno!=ENOENT);
return(false);
}
}
else
if (stat(FindMask,&st)!=0)
{
fd->Error=(errno!=ENOENT);
return(false);
}
#ifdef _DJGPP
fd->FileAttr=_chmod(FindMask,0);
#elif defined(_EMX)
fd->FileAttr=st.st_attr;
#else
fd->FileAttr=st.st_mode;
#endif
fd->IsDir=IsDir(st.st_mode);
fd->Size=st.st_size;
fd->mtime=st.st_mtime;
fd->atime=st.st_atime;
fd->ctime=st.st_ctime;
fd->FileTime=fd->mtime.GetDos();
strcpy(fd->Name,FindMask);
*fd->NameW=0;
#ifdef _APPLE
if (!LowAscii(fd->Name))
UtfToWide(fd->Name,fd->NameW,sizeof(fd->NameW));
#elif defined(UNICODE_SUPPORTED)
if (!LowAscii(fd->Name) && UnicodeEnabled())
CharToWide(fd->Name,fd->NameW);
#endif
#endif
fd->Flags=0;
fd->IsDir=IsDir(fd->FileAttr);
return(true);
}
开发者ID:LubosD,项目名称:fatrat-unpack,代码行数:60,代码来源:find.cpp
示例12: return
size_t Archive::ReadCommentData(Array<byte> *CmtData,Array<wchar> *CmtDataW)
{
bool Unicode=SubHead.SubFlags & SUBHEAD_FLAGS_CMT_UNICODE;
if (!ReadSubData(CmtData,NULL))
return(0);
size_t CmtSize=CmtData->Size();
if (Unicode)
{
CmtSize/=2;
Array<wchar> DataW(CmtSize+1);
RawToWide(CmtData->Addr(),DataW.Addr(),CmtSize);
DataW[CmtSize]=0;
size_t DestSize=CmtSize*4;
CmtData->Alloc(DestSize+1);
WideToChar(DataW.Addr(),(char *)CmtData->Addr(),DestSize);
(*CmtData)[DestSize]=0;
CmtSize=strlen((char *)CmtData->Addr());
CmtData->Alloc(CmtSize);
if (CmtDataW!=NULL)
{
*CmtDataW=DataW;
CmtDataW->Alloc(CmtSize);
}
}
else
if (CmtDataW!=NULL)
{
CmtData->Push(0);
CmtDataW->Alloc(CmtSize+1);
CharToWide((char *)CmtData->Addr(),CmtDataW->Addr(),CmtSize+1);
CmtData->Alloc(CmtSize);
CmtDataW->Alloc(wcslen(CmtDataW->Addr()));
}
return(CmtSize);
}
开发者ID:php,项目名称:pecl-file_formats-rar,代码行数:35,代码来源:arccmt.cpp
示例13: GetPasswordText
static void GetPasswordText(wchar *Str,uint MaxLength)
{
if (MaxLength==0)
return;
#ifdef _WIN_ALL
HANDLE hConIn=GetStdHandle(STD_INPUT_HANDLE);
HANDLE hConOut=GetStdHandle(STD_OUTPUT_HANDLE);
DWORD ConInMode,ConOutMode;
DWORD Read=0;
GetConsoleMode(hConIn,&ConInMode);
GetConsoleMode(hConOut,&ConOutMode);
SetConsoleMode(hConIn,ENABLE_LINE_INPUT);
SetConsoleMode(hConOut,ENABLE_PROCESSED_OUTPUT|ENABLE_WRAP_AT_EOL_OUTPUT);
ReadConsole(hConIn,Str,MaxLength-1,&Read,NULL);
Str[Read]=0;
SetConsoleMode(hConIn,ConInMode);
SetConsoleMode(hConOut,ConOutMode);
#else
char StrA[MAXPASSWORD];
#if defined(_EMX) || defined (__VMS) || defined(__AROS__)
fgets(StrA,ASIZE(StrA)-1,stdin);
#elif defined(__sun)
strncpyz(StrA,getpassphrase(""),ASIZE(StrA));
#else
strncpyz(StrA,getpass(""),ASIZE(StrA));
#endif
CharToWide(StrA,Str,MaxLength);
cleandata(StrA,sizeof(StrA));
#endif
Str[MaxLength-1]=0;
RemoveLF(Str);
}
开发者ID:BSzili,项目名称:aros-stuff,代码行数:33,代码来源:consio.cpp
示例14: normalizeFQN
void normalizeFQN(const wchar_t *source,wchar_t *dest)
{
char scratch[512];
WideToChar(source,scratch,512);
char temp[512];
normalizeFQN(scratch,temp);
CharToWide(temp,dest,512);
}
开发者ID:jjiezheng,项目名称:arachnid,代码行数:8,代码来源:sutil.cpp
示例15: strcpy
void FindFile::SetMask(const char *FindMask)
{
strcpy(FindFile::FindMask,NullToEmpty(FindMask));
#ifndef __BIONIC__
if (*FindMaskW==0)
CharToWide(FindMask,FindMaskW);
#endif
FirstCall=true;
}
开发者ID:brianwoo,项目名称:cm11_grouper,代码行数:9,代码来源:find.cpp
示例16: CharToWide
bool CharToWide(const char *Src,wchar *Dest,size_t DestSize)
{
bool RetCode=true;
*Dest=0; // Set 'Dest' to zero just in case the conversion will fail.
#ifdef _WIN_ALL
if (MultiByteToWideChar(CP_ACP,0,Src,-1,Dest,(int)DestSize)==0)
RetCode=false;
#elif defined(_APPLE)
UtfToWide(Src,Dest,DestSize);
#elif defined(MBFUNCTIONS)
size_t ResultingSize=mbstowcs(Dest,Src,DestSize);
if (ResultingSize==(size_t)-1)
RetCode=false;
if (ResultingSize==0 && *Src!=0)
RetCode=false;
if ((!RetCode || *Dest==0 && *Src!=0) && DestSize>NM && strlen(Src)<NM)
{
/* Workaround for strange Linux Unicode functions bug.
Some of wcstombs and mbstowcs implementations in some situations
(we are yet to find out what it depends on) can return an empty
string and success code if buffer size value is too large.
*/
return(CharToWide(Src,Dest,NM));
}
#else
if (UnicodeEnabled())
{
#if defined(_EMX) && !defined(_DJGPP)
int len=Min(strlen(Src)+1,DestSize-1);
if (uni_toucs((char*)Src,len,(UniChar*)Dest,(size_t*)&DestSize)==-1 ||
DestSize>len)
DestSize=0;
RetCode=false;
#endif
}
else
for (int I=0;I<DestSize;I++)
{
Dest[I]=(wchar_t)Src[I];
if (Src[I]==0)
break;
}
#endif
// We tried to return the zero terminated string if conversion is failed,
// but it does not work well. MultiByteToWideChar returns 'failed' code
// even if we wanted to convert only a part of string and passed DestSize
// smaller than required for fully converted string. Such call is the valid
// behavior in RAR code and we do not expect the empty string in this case.
return(RetCode);
}
开发者ID:artifexor,项目名称:stream-unrar,代码行数:56,代码来源:unicode.cpp
示例17: EnvStrW
void CommandData::ParseEnvVar()
{
char *EnvStr=getenv("RAR");
if (EnvStr!=NULL)
{
Array<wchar> EnvStrW(strlen(EnvStr)+1);
CharToWide(EnvStr,&EnvStrW[0],EnvStrW.Size());
ProcessSwitchesString(&EnvStrW[0]);
}
}
开发者ID:abbeycode,项目名称:UnrarKit,代码行数:10,代码来源:cmddata.cpp
示例18: return
bool ScanTree::PrepareMasks()
{
ScanEntireDisk=false;
if (!FileMasks->GetString(CurMask,CurMaskW,sizeof(CurMask)))
return(false);
CurMask[ASIZE(CurMask)-1]=0;
CurMaskW[ASIZE(CurMaskW)-1]=0;
#ifdef _WIN_32
UnixSlashToDos(CurMask);
#endif
// We wish to scan entire disk if mask like c:\ is specified
// regardless of recursion mode. Use c:\*.* mask when need to scan only
// the root directory.
ScanEntireDisk=IsDiskLetter(CurMask) && IsPathDiv(CurMask[2]) && CurMask[3]==0;
char *Name=PointToName(CurMask);
if (*Name==0)
strcat(CurMask,MASKALL);
if (Name[0]=='.' && (Name[1]==0 || Name[1]=='.' && Name[2]==0))
{
AddEndSlash(CurMask);
strcat(CurMask,MASKALL);
}
SpecPathLength=Name-CurMask;
// if (SpecPathLength>1)
// SpecPathLength--;
bool WideName=(*CurMaskW!=0);
if (WideName)
{
wchar *NameW=PointToName(CurMaskW);
if (*NameW==0)
strcatw(CurMaskW,MASKALLW);
if (NameW[0]=='.' && (NameW[1]==0 || NameW[1]=='.' && NameW[2]==0))
{
AddEndSlash(CurMaskW);
strcatw(CurMaskW,MASKALLW);
}
SpecPathLengthW=NameW-CurMaskW;
}
else
{
wchar WideMask[NM];
CharToWide(CurMask,WideMask);
SpecPathLengthW=PointToName(WideMask)-WideMask;
}
Depth=0;
strcpy(OrigCurMask,CurMask);
strcpyw(OrigCurMaskW,CurMaskW);
return(true);
}
开发者ID:tanbo800,项目名称:jdownloader-service,代码行数:55,代码来源:scantree.cpp
示例19: GetWideName
wchar* GetWideName(const char *Name,const wchar *NameW,wchar *DestW)
{
if (NameW!=NULL && *NameW!=0)
{
if (DestW!=NameW)
strcpyw(DestW,NameW);
}
else
CharToWide(Name,DestW);
return(DestW);
}
开发者ID:1ibraheem,项目名称:xbmc,代码行数:11,代码来源:pathfn.cpp
示例20: CharToWide
bool CWord::IsComplexWordAsDate() const
//for treating dates like 11.06.07 as Words
{
if (m_typ != Complex)
return false;
static const Wtroka allowed = CharToWide("-.\\/11234567890г");
const Wtroka& str = GetText();
return str.find_first_not_of(allowed) == Wtroka::npos;
}
开发者ID:Frankie-666,项目名称:tomita-parser,代码行数:11,代码来源:word.cpp
注:本文中的CharToWide函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论