To All:
Recently, when discussing and improving a batch script for regular backups with Brother namejm, a problem was encountered and I am now bringing it up for everyone's advice.
After enabling the auto-completion feature with cmd /f:on, it was found that if there are directories or files with Chinese names in the test directory, using Ctrl+D or Ctrl+F can normally complete the directory or file name. However, when continuing to use Ctrl+D or Ctrl+F to complete and the next directory or file name is shorter than the completed directory or file name, after displaying the new directory or file name, the old directory and file name does not completely disappear, but leaves a certain trace.
For example, the test folder has only two files named "Long Filename" and "Short Name". Then, after enabling cmd /f:on for auto-completion, pressing Ctrl+F for the first time will display "Long Filename", and pressing Ctrl+F for the second time will display "Short Name Name".
It needs to be noted that the residual trace of the old file will not affect the normal recognition of the new file.
It is analyzed that this should be caused by the auto-completion not correctly handling multi-byte character (including Chinese) file names. In the above test, before the second auto-completion, it only cleared the first three Chinese characters of the previous display, with a width equivalent to 6 English characters. This seems to be because cmd calculates the string length of the previous completed file name according to the Unicode rule as 4, plus the two characters 0d/0a represented by the carriage return, totaling 6. That is to say, cmd rewrites the original file name with 6 English blank characters to clear its display content, but may not have considered that the display width of multi-byte characters is several times that of English characters.
File Backup Tool
http://www.cn-dos.net/forum/viewthread.php?tid=20747&fpage=1
Recently, when discussing and improving a batch script for regular backups with Brother namejm, a problem was encountered and I am now bringing it up for everyone's advice.
After enabling the auto-completion feature with cmd /f:on, it was found that if there are directories or files with Chinese names in the test directory, using Ctrl+D or Ctrl+F can normally complete the directory or file name. However, when continuing to use Ctrl+D or Ctrl+F to complete and the next directory or file name is shorter than the completed directory or file name, after displaying the new directory or file name, the old directory and file name does not completely disappear, but leaves a certain trace.
For example, the test folder has only two files named "Long Filename" and "Short Name". Then, after enabling cmd /f:on for auto-completion, pressing Ctrl+F for the first time will display "Long Filename", and pressing Ctrl+F for the second time will display "Short Name Name".
It needs to be noted that the residual trace of the old file will not affect the normal recognition of the new file.
It is analyzed that this should be caused by the auto-completion not correctly handling multi-byte character (including Chinese) file names. In the above test, before the second auto-completion, it only cleared the first three Chinese characters of the previous display, with a width equivalent to 6 English characters. This seems to be because cmd calculates the string length of the previous completed file name according to the Unicode rule as 4, plus the two characters 0d/0a represented by the carriage return, totaling 6. That is to say, cmd rewrites the original file name with 6 English blank characters to clear its display content, but may not have considered that the display width of multi-byte characters is several times that of English characters.
File Backup Tool
http://www.cn-dos.net/forum/viewthread.php?tid=20747&fpage=1
※ Batchinger 致 Bat Fans:请访问 批处理编程的异类 ,欢迎交流与共享批处理编程心得!
