|
-
August 12th, 2009, 12:10 PM
#1
What is this file?
I have a file that has a character then alternates with a null thru the entire file. When I open it in notepad i just see the characters next to each other no null or spaces. I see the nulls as squares in word if i open it that way. When i read the file i have to read it 1 byte at a time so that i can grab the character and skip the null, grap, skip and so on.
So i have 2 questions:
1. What kind of file is this and
2. Is there a better and faster way to read this than 1 byte at a time.
I am using CFile to read it right now.
Any help would be very much appreciated.
Thank you,
-
August 12th, 2009, 01:18 PM
#2
Re: What is this file?
It is probably a binary file (as opposed to text files). Yes, you can read as many characters as you want at a time. Function Read() gets a pointer to a buffer and the size of the buffer. It can be any size you want.
-
August 12th, 2009, 01:28 PM
#3
Re: What is this file?
when i do this:
CFile myfile;
myfile.open("C:\file.txt");
myfile.Read (pbuf,100);
It still gets the NULLs too and really messes me up when i try to move it to a CString. So what is the best way to read this? I need to remove the NULLs before i put the info into a DB.
Thanks,
Last edited by strych9; August 12th, 2009 at 01:31 PM.
-
August 12th, 2009, 02:40 PM
#4
Re: What is this file?
Possibly a unicode representation?
-
August 12th, 2009, 03:40 PM
#5
Re: What is this file?
Try using CStdioFile::ReadString
-
August 12th, 2009, 04:01 PM
#6
Re: What is this file?
It's probably a UTF-16 encoded file.
-
August 13th, 2009, 08:34 AM
#7
Re: What is this file?
can anyone give some code on how to read this?
Thanks,
-
August 13th, 2009, 08:42 AM
#8
Re: What is this file?
Hi,
You mention CString, so I guess you are using MFC.
Compile your application as unicode and it should work fine, use CFile::Read to read it into the CString.
Alan
-
August 13th, 2009, 04:43 PM
#9
Re: What is this file?
where is the setting to compile as unicode?
-
August 14th, 2009, 04:48 AM
#10
-
August 14th, 2009, 12:52 PM
#11
Re: What is this file?
Last edited by strych9; August 15th, 2009 at 12:52 PM.
-
August 15th, 2009, 12:46 PM
#12
Re: What is this file?
Well when i did that i got 51 errors on a program that was working? Any ideas?
-
August 15th, 2009, 01:45 PM
#13
Re: What is this file?
Can you post the file? Or where can I find it? Maybe once I can look at it I might be able to help.
-
August 15th, 2009, 04:56 PM
#14
Re: What is this file?
 Originally Posted by strych9
I have a file that has a character then alternates with a null thru the entire file.
This sounds like a Unicode version of a file that used to be in a single-byte character set,
For example, a non-Unicode English text file that has been "Unicode-ized" will have the property you're describing.
Regards,
Paul McKenzie
-
August 16th, 2009, 01:42 AM
#15
Re: What is this file?
what is the best way to read it?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|