How to convert binary string to char string ?
[Post re-arranged to make more sense.
Also, please don't CC: copies of news posting without marking them as such.]
Quote:
> > There is no such thing as "binary string" and a "char string". A string
> > is a sequence of characters. Those characters can be ones that you'd
> > consider "printable" (for want of a better term) and non-printable.
> > > I read COM port ( I can't to use CT.LIB ! ) and have sequense of bytes .
> > > What to do next ?
> > That all depends on what you want to do. What are you actually trying to
> > do?
> Hello Dave ! Thank you for your letter . Excuse for my bad english .
> You wrote about "printable" or "non-printable" . So I am receiving from
> COM port "non-printable" char sequence . How to convert this sequence to
> "printable" char sequence ?
Again, that really depends on what you want to really do. You can't really
convert a non-printable character to a printable character1 because, if you
did, you'd no longer have the byte value you had in the first place.
Quote:
> I know that COM port read information in bytes.
Also keep in mind that a string is nothing more than a sequence of bytes.
This:
,----
| "Hello World"
`----
is a string in Clipper. So is this:
,----
| chr( 1 ) + chr( 2 ) + chr( 3 ) + chr( 4 ) + chr( 5 ) + chr( 6 )
`----
The former would be considered a string of "printable characters", the
latter would be considered to be a string of "non-printable characters"
(sometimes referred to as "control characters").
In either case you've got a sequence of bytes, just like you'd read from the
COM port with the function you're using.
Quote:
> In Clipper Tools is perfect function cStr := COM_READ( nComm ) which
> convert this sequence of "non-printable" char sequence to "printable" char
> string . But I can't to use CT.LIB . So what you can say in this situation
> ?
Hmm, reading the above I'm not totally sure about what you're asking here.
Are you asking "how can I read from the COM port"? The function you talk
about above doesn't return a string of "printable characters", it simply
returns a string (a sequence of bytes)2.
Re-reading your question it seems to me that what you're really asking is
"how can I read a string from a COM port without using a function from
Clipper Tools?". Is that what you're asking?
-----
1 Actually, in Clipper, it's hard to have "non-printing" when using the
default terminal layer. But that's a slightly different issue...
2 I'm inferring the output from your example, I've never seen a copy of
Clipper Tools in my life. Well, that isn't quite true, I've seen a copy on
someone's shelf.
--
Take a look in Hagbard's World: | w3ng - The WWW Norton Guide reader.
http://www.hagbard.demon.co.uk/ | eg - Norton Guide reader for Linux.
http://www.acemake.com/hagbard/ | weg - Norton Guide reader for Windows.
Free software, including........| dgscan - DGROUP scanner for Clipper.