01-25-2013
The ASCII char set is composed of (binary) codes from 0 to 127, including control chars, punctuation, numbers, and upper and lower case characters. Anything above does not belong to the ASCII set, but e.g. an extended ASCII set, or UTF-8, or other.
An ASCII text will be composed of lines containing only the codes below 128, but can include any control char, incl. \r. It's a unix convention to only use \n for a line separator. Other OS, like Windows or VMS, use(d) \r\n as line terminators in text files.
Any file that has codes above 128 CAN be a text file using an international char set like UTF-8, but also can be a binary file, e.g. a picture, a sound file, or a database file. (Actually, you could have a picture that has only codes below 128, but that might be a bit strange to look at...)
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello,
How to i determine via ftp commandline if files on ftp server is ascii or binary files. Like every other comon windows ftp program does it automatically.
regards
Thomas (5 Replies)
Discussion started by: congo
5 Replies
2. Shell Programming and Scripting
I want to verify the file is Binary or ascii file and accordingly I want to switch the program with ret code
ie 0 or success and 1 for failure
Can any one help me is this a correct syntex...i am getting error
#!/bin/ksh
$file filename
if
echo "ascii fie Found"
else
echo " binary... (6 Replies)
Discussion started by: u263066
6 Replies
3. Shell Programming and Scripting
hi
i am receiving a file from one system , i have to verify the format of the file data i.e whether the data is in acii format or binary format,
please help
thanks in advance
satya (1 Reply)
Discussion started by: Satyak
1 Replies
4. Shell Programming and Scripting
Hi,
Is there a way to convert the binary file to ascii . the binary file is pipe delimited.
from source the file(pipe delimited) is ftped to mainframe and from mainframe it is ftped to the unix box using binary format. Is there a way to change it back to ascii and view it?
Thanks! (3 Replies)
Discussion started by: dnat
3 Replies
5. Programming
Hi All,
Please suggest me how to read a binary file in text or ASCII format.
thanks
Nagendra (3 Replies)
Discussion started by: Nagendra
3 Replies
6. UNIX for Dummies Questions & Answers
Hello all,
I am working with ftp servers in unix, and always I have to get and put files but I don't know exactly if I have to get or put them as an ascii or binary. Some files that I use are: .txt, .sav, .fmb, .pct, .sh, .ksh, .dat, .log.
Somebody can tell me what is the difference between... (2 Replies)
Discussion started by: Geller
2 Replies
7. Linux
Hi Guys,
I have an issue whereby I package up an rpm and when I deploy it, the binary filesizes differ from what I packaged up from the SOURCE directory.
from source - -rwxrwxr-x 1 user group 685156 Sep 26 15:50 cybAgent.bin
after install - -rwxr-xr-x 1 user group 683388 Oct 16 11:10... (4 Replies)
Discussion started by: gazza-o
4 Replies
8. Shell Programming and Scripting
Hi All,
I have a binary file which is being exported from a Database, and i need to convert that to ASCII format. How can i achieve that? And this solution should work for any file which is given to us; means they will give different files from different tables.
Thanks in advance. (8 Replies)
Discussion started by: baranisachin
8 Replies
9. Shell Programming and Scripting
Hi All ,
I have a mainframe file which contains the data in EBCDIC format.I have downloaded this file from mainframe to windows in binary format(unreadable raw data).Now I want convert this file to ASCII format(readable format data) through Unix command.I have tried iconv but that is not working... (2 Replies)
Discussion started by: STCET22
2 Replies
10. Shell Programming and Scripting
I need to convert a binary file which in encoded using base32 encoding technique and convert that into readible ASCII so that i can load the same in DB.
is there any command to do the same.
sample from the binary file lools like :
... (18 Replies)
Discussion started by: krk
18 Replies
LEARN ABOUT OSX
ascii2addr
ADDR2ASCII(3) BSD Library Functions Manual ADDR2ASCII(3)
NAME
addr2ascii, ascii2addr -- Generic address formatting routines
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <arpa/inet.h>
char *
addr2ascii(int af, const void *addrp, int len, char *buf);
int
ascii2addr(int af, const char *ascii, void *result);
DESCRIPTION
The routines addr2ascii() and ascii2addr() are used to convert network addresses between binary form and a printable form appropriate to the
address family. Both functions take an af argument, specifying the address family to be used in the conversion process. (Currently, only
the AF_INET and AF_LINK address families are supported.)
The addr2ascii() function is used to convert binary, network-format addresses into printable form. In addition to af, there are three other
arguments. The addrp argument is a pointer to the network address to be converted. The len argument is the length of the address. The buf
argument is an optional pointer to a caller-allocated buffer to hold the result; if a null pointer is passed, addr2ascii() uses a statically-
allocated buffer.
The ascii2addr() function performs the inverse operation to addr2ascii(). In addition to af, it takes two arguments, ascii and result. The
ascii argument is a pointer to the string which is to be converted into binary. The result argument is a pointer to an appropriate network
address structure for the specified family.
The following gives the appropriate structure to use for binary addresses in the specified family:
AF_INET struct in_addr (in <arpa/inet.h>)
AF_LINK struct sockaddr_dl (in <net/if_dl.h>)
AF_INET and AF_LINK constants are defined in <sys/socket.h>
RETURN VALUES
The addr2ascii() function returns the address of the buffer it was passed, or a static buffer if the a null pointer was passed; on failure,
it returns a null pointer. The ascii2addr() function returns the length of the binary address in bytes, or -1 on failure.
EXAMPLES
The inet(3) functions inet_ntoa() and inet_aton() could be implemented thusly:
#include <sys/socket.h>
#include <arpa/inet.h>
char *
inet_ntoa(struct in_addr addr)
{
return addr2ascii(AF_INET, &addr, sizeof addr, 0);
}
int
inet_aton(const char *ascii, struct in_addr *addr)
{
return (ascii2addr(AF_INET, ascii, addr)
== sizeof(*addr));
}
In actuality, this cannot be done because addr2ascii() and ascii2addr() are implemented in terms of the inet(3) functions, rather than the
other way around.
ERRORS
When a failure is returned, errno is set to one of the following values:
[ENAMETOOLONG] The addr2ascii() routine was passed a len argument which was inappropriate for the address family given by af.
[EPROTONOSUPPORT] Either routine was passed an af argument other than AF_INET or AF_LINK.
[EINVAL] The string passed to ascii2addr() was improperly formatted for address family af.
SEE ALSO
inet(3), linkaddr(3), inet(4)
HISTORY
An interface close to this one was originally suggested by Craig Partridge. This particular interface originally appeared in the INRIA IPv6
implementation.
AUTHORS
Code and documentation by Garrett A. Wollman, MIT Laboratory for Computer Science.
BUGS
The original implementations supported IPv6. This support should eventually be resurrected. The NRL implementation also included support
for the AF_ISO and AF_NS address families.
The genericity of this interface is somewhat questionable. A truly generic interface would provide a means for determining the length of the
buffer to be used so that it could be dynamically allocated, and would always require a ``struct sockaddr'' to hold the binary address.
Unfortunately, this is incompatible with existing practice. This limitation means that a routine for printing network addresses from arbi-
trary address families must still have internal knowledge of the maximum buffer length needed and the appropriate part of the address to use
as the binary address.
BSD
June 13, 1996 BSD