|
|
std::ostringstream and \r\n
Hi,
I'm using ostringstream and I'd like to generate \r\n line ends
instead of \n ones.
Is there a flag for this?
Or should I just insert the \r myself?
|
|
0
|
|
|
|
Reply
|
OlafvdSpek (15)
|
5/3/2006 6:25:47 PM |
|
Olaf van der Spek wrote:
> Hi,
>
> I'm using ostringstream and I'd like to generate \r\n line ends
> instead of \n ones.
> Is there a flag for this?
No, only for file streams.
> Or should I just insert the \r myself?
Yes.
Tom
|
|
0
|
|
|
|
Reply
|
tom_usenet3 (1118)
|
5/4/2006 12:21:24 PM
|
|
Hello Olaf,
> I'm using ostringstream and I'd like to generate \r\n line ends
> instead of \n ones. Is there a flag for this?
I don't think there is a flag...
If you are on a Windows box, "\n" will be converted to "\r\n" when
writing ***to a file*** (that is opened in "text mode"). And vice versa.
If you really need character-strings with "\r\n" line endings (why?)
you would have to convert the line-endings "manually".
Please note that line-endings are platform-specific; IIRC Windows
uses "\r\n", Linux "\n", Macintosh "\r" etc. Thus, you better just
open your text files in "text mode" and let the Standard Libary
(or the operating system) do The Right Thing (tm).
Best regards,
Tilman
|
|
0
|
|
|
|
Reply
|
tilman.kuepper (16)
|
5/4/2006 12:39:27 PM
|
|
On Thu, 4 May 2006 14:39:27 +0200, "Tilman Kuepper"
<tilman.kuepper@nexgo.de> wrote:
>Hello Olaf,
>
>> I'm using ostringstream and I'd like to generate \r\n line ends
>> instead of \n ones. Is there a flag for this?
>
>I don't think there is a flag...
>
>If you are on a Windows box, "\n" will be converted to "\r\n" when
>writing ***to a file*** (that is opened in "text mode"). And vice versa.
>If you really need character-strings with "\r\n" line endings (why?)
>you would have to convert the line-endings "manually".
I'm first writing the document to memory in my own code and then to
file via MFC.
>Please note that line-endings are platform-specific; IIRC Windows
>uses "\r\n", Linux "\n", Macintosh "\r" etc. Thus, you better just
>open your text files in "text mode" and let the Standard Libary
>(or the operating system) do The Right Thing (tm).
>
>Best regards,
>Tilman
>
>
|
|
0
|
|
|
|
Reply
|
OlafvdSpek (15)
|
5/4/2006 11:01:16 PM
|
|
Olaf van der Spek wrote:
>>
>>> I'm using ostringstream and I'd like to generate \r\n line ends
>>> instead of \n ones. Is there a flag for this?
>>
> I'm first writing the document to memory in my own code and then to
> file via MFC.
You should instruct the MFC stuff to open the file in text mode.
|
|
0
|
|
|
|
Reply
|
oldwolf (2278)
|
5/4/2006 11:42:37 PM
|
|
|
4 Replies
19 Views
(page loaded in 2.257 seconds)
|
|
|
|
|
|
|
|
|