Jump to content











Photo
- - - - -

How? Batch with set, to "translate" ascii.


  • Please log in to reply
4 replies to this topic

#1 betrand

betrand

    Frequent Member

  • Advanced user
  • 467 posts
  •  
    France

Posted 30 March 2013 - 09:42 AM

Hi, I wanna feed text to a program, but the text is not in ascii, rather in its own (I think) coding.

It was easy to decode, but feeding back is another thing.

 

After the = is the hexcode for the new code.

 

set a=c2
set b=c4
set c=c6

I want to set a text and have it translated.

set txt=This is a text.

And I want each letter to be taken and translated, and echoed 1 by 1.

set x1=%txt:~0,1%

set x2=%txt:~1,1%

etc.

echo.%x1%%x2%%x3%

 

But it doesn't echo the hexcode, it echoes the letters.

 

I liked the simplicity of this, I 'll have to look into something else.

 

Someone an idea?

(I remember a Steve Grub4dos batch where the variable was kept. link? thanks :))



#2 steve6375

steve6375

    Platinum Member

  • Developer
  • 6629 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars
  •  
    United Kingdom

Posted 30 March 2013 - 11:50 AM

Could you explain a bit more

 

First, under what OS would this be running.

What is input

What is expected output format - i.e. AA12B3  or 0xaa 0x12 0xb3 or \xaa\x12\xb3 or what?

Is the result a file containing ascii bytes or just bytes displayed to the screen?



#3 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13749 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 30 March 2013 - 12:58 PM

Well, it's not as simple as you seem to imply.

 

You could go like that, it may be simple, but it's not IMHO the right approach.

You could look in my batch hex2dec:

http://reboot.pro/to...and-hex2deccmd/

that uses a somehow "better" routine for character substitution.

 

But a much better one is the "Capitalize" routine which you can find here:

http://web.archive.o...q.faqid 262.htm

and, in a slightly simplified version, inside MakeBS.cmd:

http://reboot.pro/to...-alpha-release/

 

And yes, the above is assuming tht you are talking of Batch scripts under a Windows of the NT family.

 

You posted under "Downloads"  and this besides giving no hint about what you are after, also makes no sense.

Casually there is a sticky here:

http://reboot.pro/to...-read-me-first/

Titled "Read me first!" the idea is - besides reading it - to also understand what is in it and comply with it.

 

:cheers:

Wonko



#4 betrand

betrand

    Frequent Member

  • Advanced user
  • 467 posts
  •  
    France

Posted 30 March 2013 - 01:24 PM

Thanks both.

Yep, I meant to post under Downloads/scripts (which aren't necessarily Pe scripts),

but anyway  should fit better under Windows2003/Xp, or even 7 etc.

(or Dos if in any way possible)

 

@Wonko, Mm, yeah, you pointed me to Capitalize batch in the past, good idea.

 

@Steve, input is in set text=this is text.

output  is the equivalent characters, eg C2C4C6.

Result is echoed to a file with a header.



#5 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 13749 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 30 March 2013 - 01:32 PM

Yep, I meant to post under Downloads/scripts (which aren't necessarily Pe scripts),

but anyway  should fit better under Windows2003/Xp, or even 7 etc.

(or Dos if in any way possible)

In downloads you PROVIDE downloads!

 

Just §@ç#ing READ:

http://reboot.pro/to...-read-me-first/

 

:cheers:

Wonko






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users