DosTips.com

A Forum all about DOS Batch
It is currently 29 May 2016 17:02

All times are UTC-06:00




Post new topic  Reply to topic  [ 7 posts ] 
Author Message
 Post subject: ASCII in batch
PostPosted: 02 Apr 2012 18:16 
Offline

Joined: 20 Mar 2012 20:53
Posts: 43
I know there is a really simple solution to this problem, its just I don't know what chart to look up or what I really need

I just want to get extended ascii characters like ▓ ▒ ░ into batch, but I am unable to save files with such characters

I know of three characters ° ± ² that when put into batch, are interpreted as the three above characters, but I don't know what chart online would tell me other characters like that which are interpreted as extended ascii characters in batch

Any help is appreciated


Top
   
 Post subject: Re: ASCII in batch
PostPosted: 02 Apr 2012 18:38 
Offline

Joined: 10 Feb 2012 02:20
Posts: 5598
The font and maybe the code page you display text in has a bearing on this.

Check that the font you are using has those characters.


Top
   
 Post subject: Re: ASCII in batch
PostPosted: 02 Apr 2012 18:56 
Offline

Joined: 20 Mar 2012 20:53
Posts: 43
Found what I need here: http://www.jimprice.com/jim-asc.shtml

"Microsoft Windows ® has a different notion about what the high-order (upper 128) characters are"


Top
   
 Post subject: Re: ASCII in batch
PostPosted: 02 Apr 2012 19:40 
Offline
Expert

Joined: 13 Jan 2012 21:24
Posts: 469
You don't tell the purpose of getting those characters in a batch file to begin with. If that's for making or checking pathnames on disk, then all you need is to get the codepage matching between the editor used to save the batch file, and the cmd prompt used to execute it. If it's for echo and console display purposes, you additionally need a font which carries those characters.

MrKnowItAllxx wrote:
I just want to get extended ascii characters like ▓ ▒ ░ into batch, but I am unable to save files with such characters

Use a better editor, then ;-) one which allows you to choose the target codepage.

Barring that, paste your characters into Notepad, Save-As with encoding set to Unicode, choose a name say "etc.txt". Then open a cmd prompt, "chcp 437" (replace "437" by the codepage you want), then "type etc.txt >etc-437.txt". At this point, "etc-437.txt" would be an 8-bit extended-ASCII text file saved in codepage 437.

However, I don't think that's the question you really meant to ask.

MrKnowItAllxx wrote:
I don't know what chart online would tell me other characters like that which are interpreted as extended ascii characters in batch.

Batch files are 8-bit text, and all characters are interpreted. However, the _interpretation_ of character codes above 127 depends on the active codepage, because there is no single "extended ASCII" standard.

You can find the mappings for different codepages at http://msdn.microsoft.com/en-us/goglobal/bb964653, for example
- http://msdn.microsoft.com/en-us/goglobal/cc305156 (OEM 437);
- http://msdn.microsoft.com/en-us/goglobal/cc305145 (ANSI 1252).

MrKnowItAllxx wrote:
Found what I need here: http://www.jimprice.com/jim-asc.shtml ... "Microsoft Windows ® has a different notion about what the high-order (upper 128) characters are"

That's not a bad summary, but it works better if one is already familiar with the 7-bit-ASCII vs 8-bit-extended matters, and the mechanics of Unicode mappings.

Liviu


Top
   
 Post subject: Re: ASCII in batch
PostPosted: 03 Apr 2012 17:16 
Offline

Joined: 20 Mar 2012 20:53
Posts: 43
Thanks Liviu, I hadn't known anything about codepages or that you could change the codepage in cmd with "chcp xxx", definitely seems useful to know. Also, after a little while I figured out that I am able to type in the alt-codes for the characters I want directly in batch and output them to a file where they become practical nonsense but when I then "type" that file I get the original characters again.

And as for what I'm doing, I am simply creating a maze game, and want to use extended ascii characters to make the maps look more appealing.

Thanks for all the help :)


Top
   
 Post subject: Re: ASCII in batch
PostPosted: 03 Apr 2012 22:51 
Offline
Expert

Joined: 13 Jan 2012 21:24
Posts: 469
MrKnowItAllxx wrote:
Also, after a little while I figured out that I am able to type in the alt-codes for the characters I want directly in batch and output them to a file where they become practical nonsense but when I then "type" that file I get the original characters again.

Careful there ;-) The ALT-key input trick doesn't shield you from codepage pitfalls. Note that ALT+xyz is translated based on the default OEM codepage, while ALT+0xyz is taken as an ANSI code. The two do not necessarily result in the same character, see for example http://www.microsoft.com/resources/docu ... x?mfr=true.

Liviu


Top
   
 Post subject: Re: ASCII in batch
PostPosted: 10 Apr 2012 14:57 
Offline

Joined: 11 Nov 2011 12:04
Posts: 32
I'm a bit late for this, aren't I?

Use the alt code (█ = Alt + 219) using the number with a 0 in front of it. (Û = Alt + 0219)
Code:
@echo off
echo Û
echo ±
echo °
pause


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 7 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: sambul35 and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited