[fpc-pascal] represent data string in hex?

wkitty42 at windstream.net wkitty42 at windstream.net
Sat Sep 21 11:15:27 CEST 2013


On Friday, September 20, 2013 12:47 PM, Bart <bartjunk64 at gmail.com> wrote: 
> On 9/20/13, wkitty42 at windstream.net <wkitty42 at windstream.net> wrote: 
>  
> > 
> > a[n] := #255;  // works 
> > a[n] := $ff;     // does not work 
> > 
> > ideally, there would be multiple bytes... 
> > 
> > a[n] := $C2AD  or  a[n] := $C2$AD 
> > 
>  
> Not sure what you want: 
>  
> a[n] := #$FF;  (which equals a[n] := #255) 
> a[n] := '$FF' (note the single quotes), assuming a[n] is of type String. 

yeah, the singles are bad examples... i'm really wanting the multiple byte format to work... i tried both and was told "expected string but found byte" or "word"... it is for a translation table... in quoted-printable, everything is equalsXX... the same codes are used in utf-8... so i thought if i could just copy them directly into my array and then change the equals to dollar...

i ended up getting it to work by wrapping each piece with chr() but that's really ugly visually when looking at the code to see the side by side character and replacement tables...

a[n] := chr($C2)+chr($AD) for two byte codes...

the end result is to translate as much as possible to CP437 for posting in 7bit medium and distribution for others to read... numerous of those reading are sight impaired and do not use any GUI at all... plain DOS 6 for many of them as newer stuff just doesn't work well for them... utf-8 and quoted-printable are just pure fecal material in those environments... so i'm having to do this conversion stuff... in the above two byte example, it is a "soft hyphen" which will be replaced with the good old-fashioned '-' (dash/minus/hyphen) character... there's hundreds of items like this that have a plain 7-bit translation but i haven't found anything that does it as needed... the trade mark, copyright, and service mark symbols are three others... '(tm)', '(c)', and '(sm)' work just fine ;)

i hope that is clearer...





More information about the fpc-pascal mailing list