![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-10 16:59 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » Restore a sentence of code copied from QQ |
| Printable Version 2,974 / 15 |
| Floor1 namejm | Posted 2007-03-10 09:44 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
I often discuss batch processing in the group. Some codes are directly posted, and when I copy them and save to a file, I find that all the content is squeezed into one line, and the carriage return places are occupied by annoying black blocks. There are as many black blocks as there are carriage returns. To test the code, I generally have to break lines manually, which is very troublesome. Do we just have to endure such torture?
Today in the group, someone asked me how to use batch processing to solve this problem. During the testing process, I accidentally discovered a very useful statement and share it with you: Usage method: Save this code as a batch file that is not test.cmd, save the code copied from QQ in the test.txt file, run the above code, and then open test.cmd to see what? Hehe, is the code restored? By extension, as long as it is content copied from QQ, this code can be used to restore it. Don't ask me what the principle is, because I don't know either ^_^, but there is an article worth referring to. Please see: How to extract content on different lines |
|
| Floor2 slore | Posted 2007-03-10 09:48 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
Just open it with UE. Or save it as an RTF file and copy it... Then when you open it with TXT, it's gone.
|
|
| Floor3 zh159 | Posted 2007-03-10 09:56 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
Open the TXT file with Notepad and save it once, and that's it.
|
|
| Floor4 jmz573515 | Posted 2007-03-10 10:42 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
Nice stuff, bump it up!
Solves quite a few practical problems... |
|
| Floor5 electronixtar | Posted 2007-03-10 10:59 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
Because the carriage return in Windows is 0x0D0A, while in QQ only 0x0D is used. more will automatically recognize the encoding and carriage return.
|
|
| Floor6 jmz573515 | Posted 2007-03-10 11:00 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
I want to ask electronixtar, how to represent 0x0D in QQ in VBS?
|
|
| Floor7 electronixtar | Posted 2007-03-10 11:04 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
| Floor8 baomaboy | Posted 2007-03-10 11:04 |
| 银牌会员 Posts 554 Credits 1,513 | |
|
Usually, carriage return and line feed are used together.
If you can see black blocks, it means there is only a carriage return character and no line feed character. In fact, as long as you replace the 'carriage return character' with 'carriage return + line feed', it will be okay. Save the following code as a vbs file, and drag the file onto this vbs file, and the generated new file will have no black blocks. Set FSO = CreateObject("Scripting.FileSystemObject") Set Args = WScript.Arguments Set ReadFile = FSO.OpenTextFile(Args(0), 1) Str=ReadFile.ReadAll ReadFile.Close Str=Replace(Str,chr(13),chr(13)&chr(10)) Set NewFile = FSO.CreateTextFile(FSO.BuildPath(FSO.GetParentFolderName(Args(0)),"newfile.txt"), True) NewFile.Write Str NewFile.Close Set FSO = Nothing The newfile.txt in the code is the name of the new file you want to generate! |
|
| Floor9 baomaboy | Posted 2007-03-10 11:09 |
| 银牌会员 Posts 554 Credits 1,513 | |
|
Hehe, my internet speed here is too slow. It took a long time to refresh. Brother electronixtar has already explained, learned it ^_^
[ Last edited by baomaboy on 2007-3-10 at 11:11 AM ] |
|
| Floor10 jmz573515 | Posted 2007-03-10 11:09 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
Why can't replace("内容",chr(13),vbcrlf) work?
|
|
| Floor11 jmz573515 | Posted 2007-03-10 11:14 |
| 银牌会员 Posts 464 Credits 1,212 | |
|
What I tried on the 8th floor, but it still doesn't work....
|
|
| Floor12 csx163 | Posted 2007-03-10 12:17 |
| 初级用户 Posts 45 Credits 97 | |
|
The carriage return encoding of the UNIX system is different from that of WINDOWS
|
|
| Floor13 csx163 | Posted 2007-03-10 12:20 |
| 初级用户 Posts 45 Credits 97 | |
|
Then, may I ask, I have a folder of text files, how to batch convert them to Windows format?
|
|
| Floor14 anqing | Posted 2007-03-10 22:22 |
| 高级用户 Posts 413 Credits 859 | |
|
Nice
|
|
| Floor15 yahooboby | Posted 2007-03-11 00:05 |
| 初级用户 Posts 3 Credits 111 | |
|
Use replacement is also okay.. Switch back to carriage return OK
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |