Hi all: My problem is: I have a file which content is like below 100f1010 0f100f10 0e100e10 (The format is ASCII text, with CRLF line terminators, which I got by typing "file myfile" and thanks Manish and Grigoriy ). Right now I want to transfer it to hex format each 2 chars and save it as binary file like below: 0f 10 0f 10 original input Ox0f 0x10 0x0f 0x10 final output 0e 10 0e 10 original input 0x0e 0x10 0x0e 0x10 final output And my function is like below while(!feof(fIn)) { fgets(cTemString, 3, fIn); uValue = atoi(cTemString); fwrite(&uValue, sizeof(unsigned char),1,fout); } But I have some problems right now, 1. Does there have any atoh function, transfer char* to hex value. 2. How can I avoid getting the control character, like /r /c,etc by using fgets? I know I can use fgetc and isspace to check whether the character is control character. But it is too slow, since read 1 char each time. Can any acceleration help me? Appreciate all your help, cckuo -----Original Message----- From: kernelnewbies-bounce@xxxxxxxxxxxx [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf Of Grigoriy Shcherbyak Sent: Wednesday, December 19, 2007 4:42 PM To: kernelnewbies@xxxxxxxxxxxx Subject: Re: how to know a binary or text file and show all the information in file Hello! "File" utility should give you the information on what this file is. Just run file myfile.dat. If you mean that you need to transform binary in printable form, then look to base64 coding functionality from openssl package - it can do this. Many tools can open binary files, it depends on what you want it to do. Regards, On Dec 19, 2007 10:18 AM, <C_C_Kuo@xxxxxxxxxxxxxx> wrote: > Dear all: > Could someone tell me how to know the file is binary or ASCII? > I know both of them are stream of bytes but interpreted by different ways. > My questions are: > 1. How can I know this without opening it? > 2. how can I see all the information in a file, include all the control characters, like linein, print character and line feed, etc. > 3. Is there any tool on Linux can open binary file? > 4. Is there any tool on Linux can transfer ASCII to binary and binary to ASCII? > > Appreciate your help, > cckuo > > > > ***************** Novatek Email Confidentiality Notice ***************** > The information contained in this electronic communication, and any electronic attachments, is confidential or legally privileged and may be subject to protection under the law. It is intended only for the named recipient above. If you have received this communication in error, or are not the named recipient, please immediately notify the sender via reply email and delete this communication from your computer system, and destroy all copies of this communication along with any attachments. Thank you for your cooperation. > > Copyright Novatek 2006-2007 All Rights Reserved > > -- > To unsubscribe from this list: send an email with > "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx > Please read the FAQ at http://kernelnewbies.org/FAQ > > N猛y鈉槃逶??zv陽z ***************** Novatek Email Confidentiality Notice ***************** The information contained in this electronic communication, and any electronic attachments, is confidential or legally privileged and may be subject to protection under the law. It is intended only for the named recipient above. If you have received this communication in error, or are not the named recipient, please immediately notify the sender via reply email and delete this communication from your computer system, and destroy all copies of this communication along with any attachments. Thank you for your cooperation. Copyright Novatek 2006-2007 All Rights Reserved -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ