View unanswered posts | View active topics It is currently 22 Dec 2014 15:19



Post new topic Reply to topic  [ 7 posts ] 
ASCII in batch 
Author Message

Joined: 20 Mar 2012 20:53
Posts: 43
Post ASCII in batch
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


02 Apr 2012 18:16
Profile

Joined: 10 Feb 2012 02:20
Posts: 4503
Post Re: ASCII in batch
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.


02 Apr 2012 18:38
Profile

Joined: 20 Mar 2012 20:53
Posts: 43
Post Re: ASCII in batch
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"


02 Apr 2012 18:56
Profile
Expert

Joined: 13 Jan 2012 21:24
Posts: 443
Post Re: ASCII in batch
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


02 Apr 2012 19:40
Profile

Joined: 20 Mar 2012 20:53
Posts: 43
Post Re: ASCII in batch
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 :)


03 Apr 2012 17:16
Profile
Expert

Joined: 13 Jan 2012 21:24
Posts: 443
Post Re: ASCII in batch
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


03 Apr 2012 22:51
Profile

Joined: 11 Nov 2011 12:04
Posts: 32
Post Re: ASCII in batch
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


10 Apr 2012 14:57
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Yahoo [Bot] and 11 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 © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.