从文本文件中删除首字母
;note: use FileOpen/FileDelete/FileAppend with caution, as they can alter file content ;backup any important files before testing q:: ;remove first character from text file ;create test file vPath := A_Desktop "\MyUtf8File.txt", vEnc := "UTF-8" ;vPath := A_Desktop "\MyUtf16File.txt", vEnc := "UTF-16" ;vPath := A_Desktop "\MyAnsiFile.txt", vEnc := "CP0" if !FileExist(vPath) FileAppend, % "abcde", % "*" vPath, % vEnc ;check if file exists if !FileExist(vPath) return ;get encoding if !(oFile := FileOpen(vPath, "r")) return vEnc := oFile.Encoding oFile.Close() ;get text FileRead, vText, % vPath ;delete file FileDelete, % vPath ;append text FileAppend, % SubStr(vText, 2), % "*" vPath, % vEnc ;open file Run, % vPath return ;note: to remove 1 character each time: ;SubStr(vText, 1, -1)
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


顶一下