How to convert binary string to char string ? 
Author Message
 How to convert binary string to char string ?

Hi for all ! I want to convert binary string to char string . That it is
problem for me , because I don't know what functions can process binary
string . Concretely , I read
COM port ( I can't to use CT.LIB  ! ) and have sequense of bytes . What to
do next ?
I will be thankfull for any answer .

   Rimantas Usevicius .

begin 666 Rimantas Usevicius.vcf
M0D5'24XZ5D-!4D0-"E9%4E-)3TXZ,BXQ#0I..E5S979I8VEU<SM2:6UA;G1A

M24P[4%)%1CM)3E1%4DY%5#IR:6UA<W5 =70N;'0-"E)%5CHR,# P,#,R.50Q

`
end



Sun, 15 Sep 2002 03:00:00 GMT  
 How to convert binary string to char string ?

Quote:

> Hi for all ! I want to convert binary string to char string . That it is
> problem for me , because I don't know what functions can process binary
> string . Concretely .

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.

Quote:
> 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?

--
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.



Sun, 15 Sep 2002 03:00:00 GMT  
 How to convert binary string to char string ?
You can write one in Clipper by picking out each bit in the returned byte
values. a Big case statement can check the byte value and create a string of
1's and 0's for you.

If your reference to a "binary string" is one that contains all possible
values (including chr(0)) then just use Chr() to convert the byte values
into a character and append them to the end of a string.

-Dirk

[FUNCky Developer]
[dLESKO Inc.]

 <-- Got FUNCky? Get it now at http://www.funcky.com. FUNCky Rocks! -->



Sun, 15 Sep 2002 03:00:00 GMT  
 How to convert binary string to char string ?
   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 ? I
know that
COM port read information in bytes . 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 ?

   Best regards from Lithuania ! Rimantas

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?



Mon, 16 Sep 2002 03:00:00 GMT  
 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.



Mon, 16 Sep 2002 03:00:00 GMT  
 How to convert binary string to char string ?
FUNCTION Cvt2Print( cString )
LOCAL c, nI, cNewString := ""
   FOR nI := 1 TO LEN( cString )
      c := SUBSTR( cString, nI, 1 )
      IF c >= " "
         cNewString += c
      ELSE
         cNewString += "(" + ALLTRIM( STR( ASC( c ) ) ) + ")"
      ENDIF
   NEXT nI
RETURN cNewString

--
David G. Holm



Tue, 17 Sep 2002 03:00:00 GMT  
 How to convert binary string to char string ?
Thank , you David ! Rimantas



Quote:
> FUNCTION Cvt2Print( cString )
> LOCAL c, nI, cNewString := ""
>    FOR nI := 1 TO LEN( cString )
>       c := SUBSTR( cString, nI, 1 )
>       IF c >= " "
>          cNewString += c
>       ELSE
>          cNewString += "(" + ALLTRIM( STR( ASC( c ) ) ) + ")"
>       ENDIF
>    NEXT nI
> RETURN cNewString
> David G. Holm



Fri, 20 Sep 2002 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Converting a Hexadecimal String to a Binary String

2. Converting Binary To String (with out binary representation)

3. convert binary number to binary string

4. Convert Char String to ASCII-96 Symbol

5. Help- convert ascii code into char strings

6. converting an array of chars to a string

7. how to convert float number into char string?

8. String length of a binary string?

9. CIN: Converting a C String to a LabVIEW String

10. String#split converts string args to regexes -- ?

11. Converting a binary string to a number...

12. how convert decimal string to hexa string

 

 
Powered by phpBB® Forum Software