Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting Binary to ASCII
Message
De
23/06/1999 17:38:43
 
 
À
23/06/1999 09:30:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00232596
Message ID:
00233234
Vues:
35
>>>Is there a function or an easy way to convert Binary data to ASCII data?
>>
>>It depends on what you mean here. Binary data and ASCII data are essentially the same thing - long sequences of 8-bit bytes. ASCII data doesn't contain some specific byte values that aren't represented as printable characters, and typically, an End-Of-File character (CHR(26) in VFP terms) is used to indicate the end of the ASCII text file. Binary data can contain any and all values, and since all values can occur anywhere in the file, no specific character marks the end of file - the operating system or device has to tell you when you've reached the end of the data.
>>
>>Since binary data can contain non-printing values, some alternate means of representation must be used to make it readable. One of the more common approaches is hexadecimal display representation, which uses two ASCII characters per binary byte, each character value repesenting a hexadecimal digit. For example, a EOF character (CHR(26)) above would be represented as the string 1A: (1 * 16) + A(10). You can use the TRANSFORM function to convert the value of a byte from a binary file (ASC(byte in string)) for output purposes.
>>
>>If this isn't what you mean, please tell us what the difference is between the binary file that you have and the ASCII representation that is needed.
>
>Ed, I have a binary file and I know the field lenghts in the record. I have to convert binary fields to ASCII fields in a text file. I would like to read a binary record and convert it to a text ASCII record.

OK, you have a fixed length record, and you know what the lengths of the fields are. Do you also know the data types of each field? There may be simple conversion routines available to convert a binary number to it's ASCII or VFP representation (for example, converting an Intel-format LONG is fairly easy; various floating point types are more difficult.) If the data is encoded using a format like EBCDIC, you may well be able to use native VFP functions to translate. Without more detail, it's hard to say if it's doable, but I'd suspect that a combination of low-level file I/O to read the records and some conversion functions may make it simple.

If the format is one of many widely-supported formats, you might look at a package like Monarch or Data Junction to do the conversions for you, too.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform