Solved

.bat file does not understand ø symbol

Posted on 2010-08-30
15
1,084 Views
Last Modified: 2012-05-10
Hi,

I have batch file that call calls a file with ø symbol in it.

If I copy and paste the script in cmd in runs fine, however from the batch script it doesnt. The ø come out like this ° , and I get and error saying it cannot find the file

can anyone help?
0
Comment
Question by:Dan560
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +5
15 Comments
 
LVL 39

Accepted Solution

by:
Krzysztof Pytko earned 167 total points
ID: 33557989
Because console uses different code page as I remember :)
Run cmd from command-line

type

edit

and retype all your script there and save it as something.bat

Try then once again :]
0
 
LVL 1

Expert Comment

by:Bondy74
ID: 33558038
HI Dan

See if this link helps, it talks about adding code page 865 to the O/s so Dos can see ø

http://www.uwe-sieber.de/codepage_e.html

Regards Peter
0
 
LVL 6

Expert Comment

by:bluepig
ID: 33558715
I have a dumb question - can't you rename the called file and get rid of the undesirable character? It's bad practice to use non-standard characters in file names.
OK, now for a useful suggestion - can you modify the batch file to use the generated 8.3 short name? There is a good chance it will not include the non-standard character.
0
Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

 
LVL 13
ID: 33559374
it's not a matter of displaying them though  it's a matter of reading and writing them whcih should be fine reguardless of which code page you are in.

In my experiance on another script it turned out that ° was treated as a reserved character in the batch file, meaning it needs to be specifically told to evaluate it as text.  What I needed to do was use the ^ escape the ° Character as so ^°.

In my case I used ^ because it was a delim in a for-loop.  If you use it as a part of a file name this will work but quotes around it should also allow you to evaluate it as literal text, did you remember to put quotes around all your variables and strings?

0
 
LVL 70

Assisted Solution

by:Qlemo
Qlemo earned 167 total points
ID: 33560629
Renaming will give you the best result ;-). And yes, it is all about code pages. Windows uses 1252, which is very similar to ISO/ANSI 8859-1. The DOS prompt uses whatever you have installed with the OS. You can try if
chcp 1252
at the start of the batch file will help, but I don't think so.
0
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 166 total points
ID: 33562130
If you wrote the script in Notepad you will find it looks different to it looks in edit or with TYPE showing it etc.  As has been said is code page / unicode etc. related.  Try editing the batch in edit instead of notepad and pasting it in there and it will be the same by default or enter it in Notepad and use CHCP in the cmd.exe window to the same code page used.  In my case for instance

CHCP 850

Steve
0
 
LVL 16

Expert Comment

by:t0t0
ID: 33573059
>> "The ø come out like this ° , and I get and error saying it cannot find the file"

When pasting your code as a batch file, replace the '°' with a 'ø' by editing the code afterwards.

Hold down the left-ALT key while typing the number '0248' on the numerical keypad. When you release the ALT key, the 'ø' should appear in your text.

Typing '248' (without the leading zero) produces just a '°'.
0
 
LVL 2

Author Comment

by:Dan560
ID: 33696491
Thanks for your help
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33697106
The correct solution is to use the right code page or to edit the batch file using edit xxx.cmd from the cmd.exe prompt or other editor within the cmd.exe window (which is effectively using the same code page).  Renaming the file is a bit of a cop-out.  Didi you try using edit as suggested ?

In any case you should be able to "accept an answer" and split points yourself.  Not sure why it has gone like this?

Steve
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 33697134
At the moment EE has some issues with the split, which goes into auto-close with 4 days grace period instead of immediate accept. I have received several of this in the last two hours. Bug report sent.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33697318
thanks Qlemo, I did wonder what was going on after getting several of them!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 33705446
Well I queried it because it came up with the "this question is being closed" and was the first I had like this with this "feature" or "bug" or whatever at the moment.  Personally I think having answer as "rename the file" isn;t really a solution.  The problem is down to what the other people have all said, i.e. it is how the character is represented, i.e. the very first post says to use edit (which I missed any said the same later myself) which stores the same character and should work.

But for a quiet life just leave it be.
0
 
LVL 16

Expert Comment

by:t0t0
ID: 33768072
I'm dismayed to find my comment (33573059) was disregarded when infact I provided a technical work-around giving the reason why you were getting the wrong symbol. If you had followed my instructions, you would NOT have had to rename your files and your batch file would have been able to process them without any worries.
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question