|
Step1[^]
Step2[^]
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
I am trying to read the Unicode output from an application.
the application writes strings out to a .txt file using :
L"Date, Time, 150"
I am trying to read the value of the number, but since it is unicode, this is not a straight ReadFile operation. Is there any way in MFC to do this nice and clean. I know C# has some built in functionality to make a conversion to interpret the text.
Thanks,
|
|
|
|
|
Every (or at least most) text-file read operations have their widechar (unicode) versions, like for fgets there is fgetws. Did you try using those?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
You just need to specify the number of bytes to read in the ReadFile API.
Unicode and non-unicode is decided based upon how it is interpreted.
So you're probably not giving the correct number of bytes to read.
Try doubling it.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
You mentioned MFC so I suggest you use CStdioFile to read text files. You have to set the flag CFile::typeBinary in order to read Unicode strings and of course your app has to be Unicode enabled.
|
|
|
|
|
When you say that the app has to be Unicode enabled, do you mean building it as Unicode as opposed to release?
|
|
|
|
|
You have to define _UNICODE and UNICODE and you have to set the Entry-Point symbol in the Linker output options to wWinMainCRTStartup
That's for both configurations, Release and Debug.
|
|
|
|
|
Oh i see... So if i just do this:
"You have to define _UNICODE and UNICODE and you have to set the Entry-Point symbol in the Linker output options to wWinMainCRTStartup"
Is that equivalent to building as unicode or does that serve a totally different purpose relating to the output of the application?
|
|
|
|
|
LCI wrote: Is that equivalent to building as unicode
Yes.
The output of your app depends entirely on the functions/classes you use for writing to files.
|
|
|
|
|
LCI wrote: do you mean building it as Unicode as opposed to release?
Unicode is not 'opposed' to Release. You can build unicode enabled applications both in debug and release modes.
|
|
|
|
|
|
Hi,
Im reading one .dat file which contains lots of data.
Im using vc++ console application.
I that i have to read particular 3rd line,27th line like this.
SO i planned to use fseek but we can give starting character number only..not line number.
How can i do that..
My code
if((stream = fopen( "D:\\phylib.dat", "r" )) == NULL )
printf( "The file 'data' was not opened\n" );
else
{
fseek( stream, 23L, SEEK_SET);
while(fgets(list, 500, stream)!=NULL)
{
....
}
My file look like this
$
/DATA
/DID = 1
/TLIQ= -100.00 400.00
/TVAP= -100.00 400.00
/TSOL= 0.00 0.0
.
.
.
./DATA
/DID = 2
/TLIQ= -100.00 400.00
/TVAP= -100.00 400.00
/TSOL= 0.00 0.00
I want to read particular /DID line to get the value in right side.Pls help me...
Anu
|
|
|
|
|
You will have to read the file line-by-line and count, you can speed this up by pre-caching some amount of the file and search for line endings in memory.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Couldn't understand.Can u give any sample code for this.
Anu
|
|
|
|
|
The rough approach:
- Read the whole file in a memory buffer.
- Scan the buffer searching for newlines.
- Stop at
n -th newline found.
It doesn't look like a daunting task to me.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
As far as I know, there's no way to go to a particular line without reading the file. An end of file is a character like any other so to be able to go to a particular line, you need to read those characters.
There would be a way if each line contained always exactly the same number of characters (then you multiply the line number by the number of characters in one line) but it doesn't seem to be the case in your example.
So, the best solution would be to read line by line using fgets and keep the interesting one.
|
|
|
|
|
Read from the file one line at a time using getline .
Then check if the first 4 characters are /DID.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
How do some of you _C.P members_ include a snip of other members' quotation in gray into your comments to reffer to?
Thank you masters!
|
|
|
|
|
When replying
- select in the OP the text you intend to quote.
- use the 'Quote Selected Text' button.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: use the 'Quote Selected Text' button
Thank you!
Now could you answer my previous question please? 
|
|
|
|
|
In MFC I can save and load rich text within a rich edit control using StreamIn or StreamOut. I wonder how to include OLE objects (e.g. bitmaps and other files) into my rich edit control. Is it possible to use StreamOut and StreamIn yet?
Thank you masters!
|
|
|
|
|
See here and here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Have a look at the EM_STREAMOUT message documentation[^] (even though the formatting seems to have been broken). That explicitly talks about different options for handling output of COM (== OLE) objects.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
In my VC++ 8.0 project I got the following errors:
(i)fatal error C1083: Cannot open include file: 'windef.h'
(ii)fatal error C1083: Cannot open include file: 'windows.h'
I searched and found those files in the PlatformSDK folder i.e
C:\Program Files\Microsoft Platform SDK\Include folder.
I included this and the corresponding lib path in the project settings.
Now I get a punch of errors in winnt.h file in which I didn't do any modifications(system file).
How do I get around these errors?
|
|
|
|
|
How did you include them into your project? Did you use #include statement? Explain little more...
|
|
|
|