Hi
I would like to ask a little bit about the value Environment.Newline: what
is it and what is the point of it? Ok, I can see in the docs that it
represents "newline" for the current platform - I assume that it is a
runtime property, and not compile time?
But won't it always be the same anyway - does dotnet run on anything other
than windows platforms? So isn't newline always the same?
And what if I have a program that uses "Environment.Newline" to generate a
string and send it to a program running on another platform - the other
platform might have a completely different "newline" concept, and therefore
to use Environment.Newline is pointless isn't it?
Thanks for any comments,
Peter 4 4447
C# implementations do not always run on Windows, no. Google for
"rotor", "mono", and "dotgnu" individually and you'll find examples of
non-Windows implementations of the C# language, compiler, and runtime
environment. as far as I know, the mono project is the furthest
advanced. they have a complete 1.1 environment written, and its all
open source. it compiles and runs anywhere Unix or Windows does.
Also, should it be the responsibility of the programmer to know exactly
what the newline character is on any given system? personally, I don't
think it should be. True, there are only two types of newline currently
if you only count the latest PC operating systems, and hopefully that
narrows to one in the future, but should it be the responsibility of the
programmer to determine what operating system he is on and write logic
that outputs the currect system newline?
jeremiah
Peter Kirk wrote: Hi
I would like to ask a little bit about the value Environment.Newline: what is it and what is the point of it? Ok, I can see in the docs that it represents "newline" for the current platform - I assume that it is a runtime property, and not compile time?
But won't it always be the same anyway - does dotnet run on anything other than windows platforms? So isn't newline always the same?
And what if I have a program that uses "Environment.Newline" to generate a string and send it to a program running on another platform - the other platform might have a completely different "newline" concept, and therefore to use Environment.Newline is pointless isn't it?
Thanks for any comments, Peter
"jeremiah johnson" <na*******@gmail.com> skrev i en meddelelse
news:%2****************@TK2MSFTNGP10.phx.gbl... Peter Kirk wrote: Hi
I would like to ask a little bit about the value Environment.Newline: what is it and what is the point of it? Ok, I can see in the docs that it represents "newline" for the current platform - I assume that it is a runtime property, and not compile time?
But won't it always be the same anyway - does dotnet run on anything other than windows platforms? So isn't newline always the same?
And what if I have a program that uses "Environment.Newline" to generate a string and send it to a program running on another platform - the other platform might have a completely different "newline" concept, and therefore to use Environment.Newline is pointless isn't it?
Thanks for any comments, Peter C# implementations do not always run on Windows, no. Google for "rotor", "mono", and "dotgnu" individually and you'll find examples of non-Windows implementations of the C# language, compiler, and runtime environment. as far as I know, the mono project is the furthest advanced. they have a complete 1.1 environment written, and its all open source. it compiles and runs anywhere Unix or Windows does.
Also, should it be the responsibility of the programmer to know exactly what the newline character is on any given system? personally, I don't think it should be. True, there are only two types of newline currently if you only count the latest PC operating systems, and hopefully that narrows to one in the future, but should it be the responsibility of the programmer to determine what operating system he is on and write logic that outputs the currect system newline?
OK, I wasn't aware that .net applications could run on other platforms -
that's great. In that case I agree it is good to have a runtime property for
such things as newline (which can vary from platform to platform).
But how do you cope with sending messages from one application to another -
where we don't know what platforms the applications are running on?
For example, my application running on a windows machine generates a string
like "hello\r\n" (where "\r\n" is the Environment.Newline), and sends this
string to another application which just happens to have been installed on a
unix machine. This machine only uses "\n" characters as newline - won't
there be problems when it sees "\r\n"? Likewise, the application on the unix
machine could send a string "hello\n" (where "\n" is Environment.Newline on
unix) to the application running on windows - the application on windows
expects "\r\n".
Peter
"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:u0**************@TK2MSFTNGP14.phx.gbl... "jeremiah johnson" <na*******@gmail.com> skrev i en meddelelse news:%2****************@TK2MSFTNGP10.phx.gbl... Peter Kirk wrote: Hi
I would like to ask a little bit about the value Environment.Newline: what is it and what is the point of it? Ok, I can see in the docs that it represents "newline" for the current platform - I assume that it is a runtime property, and not compile time?
But won't it always be the same anyway - does dotnet run on anything other than windows platforms? So isn't newline always the same?
And what if I have a program that uses "Environment.Newline" to generate a string and send it to a program running on another platform - the other platform might have a completely different "newline" concept, and therefore to use Environment.Newline is pointless isn't it?
Thanks for any comments, Peter C# implementations do not always run on Windows, no. Google for "rotor", "mono", and "dotgnu" individually and you'll find examples of non-Windows implementations of the C# language, compiler, and runtime environment. as far as I know, the mono project is the furthest advanced. they have a complete 1.1 environment written, and its all open source. it compiles and runs anywhere Unix or Windows does.
Also, should it be the responsibility of the programmer to know exactly what the newline character is on any given system? personally, I don't think it should be. True, there are only two types of newline currently if you only count the latest PC operating systems, and hopefully that narrows to one in the future, but should it be the responsibility of the programmer to determine what operating system he is on and write logic that outputs the currect system newline?
OK, I wasn't aware that .net applications could run on other platforms - that's great. In that case I agree it is good to have a runtime property for such things as newline (which can vary from platform to platform).
But how do you cope with sending messages from one application to another - where we don't know what platforms the applications are running on?
For example, my application running on a windows machine generates a string like "hello\r\n" (where "\r\n" is the Environment.Newline), and sends this string to another application which just happens to have been installed on a unix machine. This machine only uses "\n" characters as newline - won't there be problems when it sees "\r\n"? Likewise, the application on the unix machine could send a string "hello\n" (where "\n" is Environment.Newline on unix) to the application running on windows - the application on windows expects "\r\n".
That's basically correct. And until the world decides on a single form of
newline, we still have to handle this situation ourselves. I believe that
is why most internet protocols either define what sort of newline will be
used or do not use a newline at all - they cannot depend on the OS
implementations to be consistent.
--
Adam Clauss
cross-platform newlines are handled usually by XML. XML parsers
completely ignore whitespace, so newlines of any kind are just not paid
attention to.
that's how i handle cross-platform text transfer, anyway. i wrap it up
in lightweight xml in a way that makes each new line a seperate tag,
and send it that way.
i'm sure there are other ways to handle this. if you control the
applications on both ends of the connection you could simply code-in an
agreed upon character that represents newlines and honor that. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Liang |
last post by:
hi,
I want to convert a file from dos formate to unix format. This is very easy
in unix. But in dos environment, the script can't work.
The perl version I used is:5.001.
Anyone knows the...
|
by: Vamsi |
last post by:
Hi,
I am trying a basic opearation of splitting a multiline value to an
array of single lines(Actually making Address into AddressLine1,
AddressLine2).
I used Environment.NewLine in split, I...
|
by: John Bowman |
last post by:
Hi All,
I've got a simple wrapper static test method on a class to expand the
environment variables on a specified string:
public static string ExpandEnvironmentStr(string Str)
{
return...
|
by: Asha |
last post by:
greetings...
i want to split a new line from an input text area and here's what i did
string.Split("\n \r ", ",");
the result, nothing happen...
then i tried this
...
|
by: Kevin Blount |
last post by:
I've been trying all morning to find a way that will let me add new
lines to a string that will form the body of an email. The problem is
that some lines are not appearing as new line, but rather...
|
by: rossum |
last post by:
I want to declare a const multi-line string inside a method, and I am
having some problems using Environment.NewLine.
I started out with:
class foo {
public void PrintStuff() {
const...
|
by: linq936 |
last post by:
Hi,
I read in many places that the string to be outputted by printf()
must be ending with newline, for example, it should be
printf("Hello World.\n");
instead of
printf("Hello World.");
|
by: O_TEXT |
last post by:
When opening a file with open and O_TEXT, in microsoft environment, and
then reading it with read, it is done in text mode.
What does text mode exactly mean?
How is it handled in reading?
...
|
by: Cameron Simpson |
last post by:
On 17Aug2008 21:25, John Nagle <nagle@animats.comwrote:
Because $HOSTNAME is a bash specific variable, set by bash but NOT
EXPORTED! Like $0 and a bunch of other "private" variables, subprocesses...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |