It is that in Traditional C++ ,the Class "file" has a Open Method which can
specify opening a file in Text-Mode.

The Text-Mode can automaticaly Convert "\r\n" to "\n" (\13 \10 to \10).

But,I can not find a way to do this in Extention Managed C++.Net ?

Any new Solution?

Re: How to Open a File in Text-mode? by Kevin

Kevin
Mon Nov 28 13:31:04 CST 2005

See the System.Encoding class:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextencodingclasstopic.asp

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"??" <@discussions.microsoft.com> wrote in message
news:C731931C-3A3B-464B-8C5C-307DB3E8AF46@microsoft.com...
> It is that in Traditional C++ ,the Class "file" has a Open Method which
> can
> specify opening a file in Text-Mode.
>
> The Text-Mode can automaticaly Convert "\r\n" to "\n" (\13 \10 to \10).
>
> But,I can not find a way to do this in Extention Managed C++.Net ?
>
> Any new Solution?



Re: How to Open a File in Text-mode? by discussions

discussions
Mon Nov 28 21:50:03 CST 2005

First thank you,

Then,

I use the following code to try

[
//FileStream * theFile

StreamReader * FileReader = new StreamReader(theFile,Encoding::Unicode);
String * sTemp = FileReader->ReadToEnd();

Encoding * unicode = Encoding::Unicode;

FileReader->Close();

FileBuffer = new unsigned char __gc[sTemp->Length +1];
FileBuffer = unicode->GetBytes(sTemp);
FileBuffer[sTemp->Length] = '\0';
]

I notice that the double-byte Charactor is converted to two single-byte
Charactors as 8-bit usigned char . East Asia Language is converted to 0x7F+
Charactors. It works perfectly.

But the converting of "\13\10" to "\10" does not happen....


What's the correct solution of this?
Will you please give out some code?
=========================================================================

â??Kevin Spencerâ??ç¼?å??ï¼?

> See the System.Encoding class:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextencodingclasstopic.asp
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> ..Net Developer
> If you push something hard enough,
> it will fall over.
> - Fudd's First Law of Opposition
>


Re: How to Open a File in Text-mode? by Truong

Truong
Mon Nov 28 23:06:14 CST 2005

>But the converting of "\13\10" to "\10" does not happen....
>What's the correct solution of this?
Why not just replace every "\13\10" with "\10" after loading the file?


Re: How to Open a File in Text-mode? by Kevin

Kevin
Tue Nov 29 08:29:43 CST 2005

I don't believe there's any built-in mechanism for this. The
StreamReader.ReadLine method will read up to a CR or CR/LF combination, and
not read the line terminator sequence. So you could use this method, and
append the appropriate line terminator, or you could simply replace for the
whole string (which is what I think I would do).

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"??" <@discussions.microsoft.com> wrote in message
news:A175FD60-D027-48AA-8662-37983879D66A@microsoft.com...
> First thank you,
>
> Then,
>
> I use the following code to try
>
> [
> //FileStream * theFile
>
> StreamReader * FileReader = new StreamReader(theFile,Encoding::Unicode);
> String * sTemp = FileReader->ReadToEnd();
>
> Encoding * unicode = Encoding::Unicode;
>
> FileReader->Close();
>
> FileBuffer = new unsigned char __gc[sTemp->Length +1];
> FileBuffer = unicode->GetBytes(sTemp);
> FileBuffer[sTemp->Length] = '\0';
> ]
>
> I notice that the double-byte Charactor is converted to two single-byte
> Charactors as 8-bit usigned char . East Asia Language is converted to
> 0x7F+
> Charactors. It works perfectly.
>
> But the converting of "\13\10" to "\10" does not happen....
>
>
> What's the correct solution of this?
> Will you please give out some code?
> =========================================================================
>
> "Kevin Spencer"??:
>
>> See the System.Encoding class:
>>
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemtextencodingclasstopic.asp
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> ..Net Developer
>> If you push something hard enough,
>> it will fall over.
>> - Fudd's First Law of Opposition
>>
>



Re: How to Open a File in Text-mode? by discussions

discussions
Tue Nov 29 11:26:09 CST 2005

The String::Replace works

But I did not think .NET is so stiff in this aspect , I would rather use C
Library Function to make this.

A litte dispaired to .NET

Thank you all.