#17
Post
by ayce » 29 Dec 2021 14:12
My config is this:
Active code page: 1252
Unless I'm wrong, that's pretty default...
So, I'm somewhat further with analysis now. First of all : the character is meaningless, so I do't care too much what it is, and what it is meant for, my goal is to actually remove the character.
But, to do that, I MUST use a variable containing that bad character, otherwise it will be hard to rename a file, if I can't tell the system what the file is named. That is, the name WITH the character.
So, the bug/feature (whatever suits you) is that the character gets lost:
- when you copy paste it from the CMD screen, to anything
- when you redirect to a file (.CMD file, .TXT file, whatever)
Also, I noted that in Windows Explorer, the character is NOT shown. I earlier stated it is shown, but it is NOT shown in Windows Explorer.
So that means that Windows Explorer is also removing the character when it displays the name of the file. As a result, it thus displays the wrong file name.
Now, CMD displays the name correct, if you use DIR or such.
Also, and that is what the code is doing, it uses it correctly if I use it in a FOR loop. I can get that one character, and put it into a variable. I can show the content of the variable, and it would always show the correct content. ( Which, as stated earlier looks like a small flag on a pole, that's my best description).
So, the thing is that construct a simple command to change the name of the file: from the real name (with that character), to the same name, but excluding the characters I don't want, which would be just that one character here (but the code would also allow removal of any character I want). But, definately removal of useless, buggy characters is a plus. Biggest problem is that the character gets removed from the parsed result by some commands, like if.
So, if I do this:
IF %my_character%+==+ echo K
... it technically works, but the result is unreliable as my character can also be a whitespace.
I know that I should be using double quotes, but also when using double quotes, the buggy/feature behaviour is the same: the character just disappears. When it gets parsed, the character is just removed.
And, when I redirect my variable to a file
echo %my_character% > test.txt
The content of that file is, just this one character:
?
So, the problem is double:
- character gets lost while doing certain manipulation in CMD
- character gets translated incorrectly, when redirected to a file