|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
    『楼 主』:
一句话还原从QQ中复制下来的代码
使用 LLM 解释/回答一下
经常在群里讨论批处理,有些代码是直接发出来的,复制下来保存到文件中去,发现所有行的内容都挤在同一行上,有回车的地方被讨厌的小黑块占据,有多少回车就有多少黑块,想测试代码,一般得手工断行,十分麻烦,难道我们就只能忍受这样的折磨吗?
今天在群里,被别人问起如何用批处理来解决这个问题,在测试过程中,无意间发现了一条十分管用的语句,发出来和大家共享:
@echo off
more test.txt>test.cmd
使用方法:把这个代码保存为非test.cmd的批处理文件,把从QQ上复制下来的代码保存在test.txt文件中,运行以上代码,然后,打开test.cmd查看,发现了什么?呵呵,代码是不是被还原了?
推而广之,只要是从QQ上复制下来的内容,都可以用这个代码来还原。
别问我是什么原理,因为,我也不知道^_^,但是,有篇文章值得参考,请看: 如何提取不同行上的内容
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:
@echo off
more test.txt>test.cmd
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
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2007-3-10 09:44 |
|
|
slore
铂金会员
      
积分 5212
发帖 2478
注册 2007-2-8
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
用ue打开就可以了嘛。或者保存成rtf文件里复制下……再用txt看就没了。
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.
|
|
2007-3-10 09:48 |
|
|
zh159
金牌会员
     
积分 3687
发帖 1467
注册 2005-8-8
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
用写字板打开txt文件直接保存一次就OK了
Open the TXT file with Notepad and save it once, and that's it.
|
|
2007-3-10 09:56 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
不错的东东,顶上去!
解决不少实际问题...
Nice stuff, bump it up!
Solves quite a few practical problems...
|
|
2007-3-10 10:42 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
因为Windows 的回车是 0x0D0A 而QQ里只用了 0x0D 。more会自动辨认编码和回车。
Because the carriage return in Windows is 0x0D0A, while in QQ only 0x0D is used. more will automatically recognize the encoding and carriage return.
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2007-3-10 10:59 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
想问一下electronixtar,在VBS里怎么表示QQ里的 0x0D ?
I want to ask electronixtar, how to represent 0x0D in QQ in VBS?
|
|
2007-3-10 11:00 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
chr(13)
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2007-3-10 11:04 |
|
|
baomaboy
银牌会员
    
积分 1513
发帖 554
注册 2005-12-30
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
通常回车和换行是连在一起用的。
如果能看到黑块说明只有回车符而无换行符,
其实只要将‘回车符’替换为‘回车+换行’就可以了。
将下面的代码保存为vbs文件,将文件拖到这个vbs文件上生成的新文件就没黑块了
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
代码中的newfile.txt是你要生成的新文件名!
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!
|
|
2007-3-10 11:04 |
|
|
baomaboy
银牌会员
    
积分 1513
发帖 554
注册 2005-12-30
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
呵呵 我这里网速太慢 刷了好久 electronixtar兄已有说明了,学习了^_^
Last edited by baomaboy on 2007-3-10 at 11:11 AM ]
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 ]
|
|
2007-3-10 11:09 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
replace("内容",chr(13),vbcrlf)为什么不能替换呢?
Why can't replace("内容",chr(13),vbcrlf) work?
|
|
2007-3-10 11:09 |
|
|
jmz573515
银牌会员
    
积分 1212
发帖 464
注册 2006-12-13
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
8楼的我试了,还是不行....
What I tried on the 8th floor, but it still doesn't work....
|
|
2007-3-10 11:14 |
|
|
csx163
初级用户
 
积分 97
发帖 45
注册 2007-1-31
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
UNIX系统回车编码和WINDOWS不太一样
The carriage return encoding of the UNIX system is different from that of WINDOWS
|
|
2007-3-10 12:17 |
|
|
csx163
初级用户
 
积分 97
发帖 45
注册 2007-1-31
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
那么请问下 我有一个文件夹的文本文件,该如何批量转换为WINDOWS格式呢?
Then, may I ask, I have a folder of text files, how to batch convert them to Windows format?
|
|
2007-3-10 12:20 |
|
|
anqing
高级用户
   
积分 859
发帖 413
注册 2006-8-14
状态 离线
|
|
2007-3-10 22:22 |
|
|
yahooboby
初级用户
 
积分 111
发帖 3
注册 2005-4-14
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
用替换也行..换回回车OK
Use replacement is also okay.. Switch back to carriage return OK
|
|
2007-3-11 00:05 |
|