Sign-up....

字符串问题,谢谢大家来帮忙................

有一个字符串,eg : what** ,**表示(0D 0A 00 0D 00 0A)也就是回车换行,what是UNICODE的字符,是双字节的,我想把what后追加一个\r\n(也就是0D 00 0A 00)应该怎么做呀??我不会去掉(0D 0A 00 0D 00 0A)....谢谢帮忙..

[151 byte] By [msdn] at [2007-8-14 20:08:04]
# 1 Re: 字符串问题,谢谢大家来帮忙................

char str[20] = "what";

strcat(str, "\r\n");

winstonch at 2005-1-5 10:06:49 >
# 2 Re: 字符串问题,谢谢大家来帮忙................

双字节的呀,那用这个吧

wchar str[20] = _T("what");

wcscat(str, "\r\n");

winstonch at 2005-1-5 10:08:40 >
# 3 Re: 字符串问题,谢谢大家来帮忙................

晕,what我取不到,只能取到what**,怎么能把what和**分开呀??

singleperson at 2005-1-5 10:20:48 >
# 4 Re: 字符串问题,谢谢大家来帮忙................

UNICODE编码的回车怎么表示?

0D0A在UNICODE中是有效的吗/

winstonch at 2005-1-5 10:24:36 >
# 5 Re: 字符串问题,谢谢大家来帮忙................

没有效,要用_T("\r\n")这样才行,要不编译不过去

singleperson at 2005-1-5 10:30:43 >
# 6 Re: 字符串问题,谢谢大家来帮忙................

不,我是说0D0A这个编码在UNICODE中能是一个字符吗?不是指是不是回车换行

winstonch at 2005-1-5 10:34:37 >
# 7 Re: 字符串问题,谢谢大家来帮忙................

对的,在unicode中都是双字节的,0D 00 (\R) 0A 00 (\N)

singleperson at 2005-1-5 10:40:38 >
# 8 Re: 字符串问题,谢谢大家来帮忙................

那你看到0D0A把它们替换为0000不行吗?

winstonch at 2005-1-5 10:44:06 >
# 9 Re: 字符串问题,谢谢大家来帮忙................

不行,太多啦,我看文件的十六进制才能看到,要是平常文本就是一些小方块,没办法换

singleperson at 2005-1-5 12:07:38 >
# 10 Re: 字符串问题,谢谢大家来帮忙................

我是说你写个程序去换,谁让你手工换了呀

winstonch at 2005-1-5 13:04:17 >
# 11 Re: 字符串问题,谢谢大家来帮忙................

知道呀,但怎么取出what呀

singleperson at 2005-1-5 13:09:22 >
# 12 Re: 字符串问题,谢谢大家来帮忙................

你要取what干么呀?能不能把你的需求说得明白一些

winstonch at 2005-1-5 13:13:06 >
# 13 Re: 字符串问题,谢谢大家来帮忙................

是给别的程序用,我有好多单词,是UNICODE格式的,每行一个单词,结尾必须是回车换行

singleperson at 2005-1-5 13:17:57 >
# 14 Re: 字符串问题,谢谢大家来帮忙................

要写到一个文件里?还要读到一个字符串里?

是从一个文件中读出来的吗?

winstonch at 2005-1-5 13:24:36 >
# 15 Re: 字符串问题,谢谢大家来帮忙................

我得的串what**是从文件中读出来的,要生成另外一个文件把what 写到那个文件里

singleperson at 2005-1-5 13:55:43 >
# 16 Re: 字符串问题,谢谢大家来帮忙................

那不就好处理了吗,你读文件的时候遇到0D0A时,就往你新生成的文件中写0D000A00就行了

winstonch at 2005-1-5 14:07:00 >
# 17 Re: 字符串问题,谢谢大家来帮忙................

哎,也只好这么办啦

singleperson at 2005-1-5 14:09:02 >

C/C++

All Classified