⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_15019.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:15019 发表者:萤火虫 发表日期:2002-09-13 15:45:26
<br>主题:请问如何在CString里面过滤掉某特定的中文字符呢?
<br>内容:比如我得到了一个路径,里面是中文的文件名,但是我想把中文文件名去掉,得到路径,怎么过滤掉那个中文文件名?我用_T,什么都不行啊,只能过滤掉英文的扩展名
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:小戟 回复日期:2002-09-13 15:57:08
<br>内容:要是知道中文文件名,好办;<BR>不知道就匹配“\\”
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:TopLevel 回复日期:2002-09-13 16:10:16
<br>内容:CString str = TEXT(" C:\\My Folder\\我的可执行文件.exe" );<BR>str = str.Left( str.ReverseFind( '\\' ) + 1 );
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:萤火虫 回复日期:2002-09-13 16:30:03
<br>内容:再比如:<BR>str="生产商:某某地方";<BR>要过滤掉="生产商",取得"某某地方"怎么做呢?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:小戟 回复日期:2002-09-13 16:45:13
<br>内容:你还是看看CString&nbsp;&nbsp;de&nbsp;&nbsp;函数。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:萤火虫 回复日期:2002-09-13 20:47:59
<br>内容:关键的问题是:我用TrimLeft()函数,剪裁不了中文,只能剪裁英文阿
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:毛新年 回复日期:2002-09-16 10:10:01
<br>内容:如果字符串不是Unicode,最安全最保险的操作是先将字符串转换成Unicode.对Unicode进行操作,在还原<BR><BR>For Example<BR>char *pszFilePath = "C:\\Limaowell\\我的文件.txt"<BR><BR>WCHAR szWFilePath[MAX_PATH];<BR>char szFilePath[MAX_PATH];<BR>MultiByteToWideChar(CP_ACP,0,pszFilePath,strlen(pszFilePath).szWFilePath,(MAX_PATH));<BR>WCHAR *pch = wcsrchr(szWFilePath,l'\\');<BR>if(pch != NULL)<BR>&nbsp;&nbsp;*pch = 0;<BR><BR>WideCharToMultiBute(CP_ACP,0,szWFilePath,wcslen(szWFilePath),szFilePath,(MAX_PATH));<BR>这样得到的szFilePath为文件路径<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:Aikoc 回复日期:2002-09-16 10:51:22
<br>内容:_splitpath, _wsplitpath<BR>Break a path name into components.<BR><BR>void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext );<BR><BR>void _wsplitpath( const wchar_t *path, wchar_t *drive, wchar_t *dir, wchar_t *fname, wchar_t *ext );<BR><BR>Routine Required Header Compatibility <BR>_splitpath &lt;stdlib.h&gt; Win 95, Win NT <BR>_wsplitpath &lt;stdlib.h&gt; or &lt;wchar.h&gt; Win 95, Win NT <BR><BR><BR>For additional compatibility information, see Compatibility in the Introduction.<BR><BR>Libraries<BR><BR>LIBC.LIB Single thread static library, retail version <BR>LIBCMT.LIB Multithread static library, retail version <BR>MSVCRT.LIB Import library for MSVCRT.DLL, retail version <BR><BR><BR>Return Value<BR><BR>None<BR><BR>Parameters<BR><BR>path<BR><BR>Full path<BR><BR>drive<BR><BR>Optional drive letter, followed by a colon (:)<BR><BR>dir<BR><BR>Optional directory path, including trailing slash. Forward slashes ( / ), backslashes ( \ ), or both may be used.<BR><BR>fname<BR><BR>Base filename (no extension)<BR><BR>ext<BR><BR>Optional filename extension, including leading period (.)<BR><BR>Remarks<BR><BR>The _splitpath function breaks a path into its four components. _splitpath automatically handles multibyte-character string arguments as appropriate, recognizing multibyte-character sequences according to the multibyte code page currently in use. _wsplitpath is a wide-character version of _splitpath; the arguments to _wsplitpath are wide-character strings. These functions behave identically otherwise.<BR><BR>Generic-Text Routine Mappings<BR><BR>TCHAR.H Routine&nbsp;&nbsp;_UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined <BR>_tsplitpath _splitpath _splitpath _wsplitpath <BR><BR><BR>Each argument is stored in a buffer; the manifest constants _MAX_DRIVE, _MAX_DIR, _MAX_FNAME, and _MAX_EXT (defined in STDLIB.H) specify the maximum size necessary for each buffer. The other arguments point to buffers used to store the path elements. After a call to _splitpath is executed, these arguments contain empty strings for components not found in path. You can pass a NULL pointer to _splitpath for any component you don’t need.<BR><BR>Example<BR><BR>/* MAKEPATH.C */<BR><BR>#include &lt;stdlib.h&gt;<BR>#include &lt;stdio.h&gt;<BR><BR>void main( void )<BR>{<BR>&nbsp;&nbsp; char path_buffer[_MAX_PATH];<BR>&nbsp;&nbsp; char drive[_MAX_DRIVE];<BR>&nbsp;&nbsp; char dir[_MAX_DIR];<BR>&nbsp;&nbsp; char fname[_MAX_FNAME];<BR>&nbsp;&nbsp; char ext[_MAX_EXT];<BR><BR>&nbsp;&nbsp; _makepath( path_buffer, "c", "\\sample\\crt\\", "makepath", "c" );<BR>&nbsp;&nbsp; printf( "Path created with _makepath: %s\n\n", path_buffer );<BR>&nbsp;&nbsp; _splitpath( path_buffer, drive, dir, fname, ext );<BR>&nbsp;&nbsp; printf( "Path extracted with _splitpath:\n" );<BR>&nbsp;&nbsp; printf( "&nbsp;&nbsp;Drive: %s\n", drive );<BR>&nbsp;&nbsp; printf( "&nbsp;&nbsp;Dir: %s\n", dir );<BR>&nbsp;&nbsp; printf( "&nbsp;&nbsp;Filename: %s\n", fname );<BR>&nbsp;&nbsp; printf( "&nbsp;&nbsp;Ext: %s\n", ext );<BR>}<BR><BR><BR>Output<BR><BR>Path created with _makepath: c:\sample\crt\makepath.c<BR><BR>Path extracted with _splitpath:<BR>&nbsp;&nbsp;Drive: c:<BR>&nbsp;&nbsp;Dir: \sample\crt\<BR>&nbsp;&nbsp;Filename: makepath<BR>&nbsp;&nbsp;Ext: .c<BR><BR><BR>File Handling Routines<BR><BR>See Also&nbsp;&nbsp; _fullpath, _getmbcp, _makepath, _setmbcp<BR><BR><BR>--------------------------------------------------------------------------------<BR>Send feedback to MSDN.Look here for MSDN Online resources. 
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -