• (unregistered)

    [:'(]  Just another reason to cry!  WTF is this dude thinking?

  • (cs)

    Initech eh? (office space)

  • (cs) in reply to seizethedave

    I guess he thought the one-liner
    return ((char)13).ToString() + ((char)10).ToString();
    was too confoozing. ;-)

  • (unregistered) in reply to Maurits

    <FONT style="BACKGROUND-COLOR: #efefef">Oh no, that guy is SOOO stupid; if he programs this way his app is not portable at all !</FONT>

    I mean, it doesn't even have a LF function to return the newline character when his app is gonna run on unix on a ported .net framework ...

    What a n00b!

    ... erm, that is the wtf isn't it ?

    guys?

    *sound of crickets*

  • (cs) in reply to

    That is certainly ONE of them, in addition to the several which Alex mentioned in the intro post..

    So where's the triumphant "see, something horrible in a language other than VB!"?  Guess they won't stoop to "our" level.  [:)]

     

     

  • (unregistered)

    You know, I just HAVE to say that I think a number of regular posters here really need their sarcasm detectors repaired.

    You DO have a sarcasm detector, don't you?

  • (cs) in reply to
    :
    You know, I just HAVE to say that I think a number of regular posters here really need their sarcasm detectors repaired.

    You DO have a sarcasm detector, don't you?


    I do.  You were being serious weren't you?
  • (unregistered)

    Your RSS feed keeps saying any items in it are new. This is obviously kind of annyoing, so I was wondering if you could maybe just fix it? Since you're apparently using a forum, changing the RSS feed to return the topicstart-date rather than the last-post date would probably work.

  • (cs)

    WoW! Now THAT is a good one!

  • (unregistered)

    public static string CRLF = "/r/n";

    to me that's a lot cleaner...

  • (cs)

    Tame your RSS you heathen.

  • (unregistered) in reply to

    \r\n

  • (cs) in reply to

    Environment.NewLine is the way to go. Notice they didn't call it Environment.CRLF [:P]

    I think this board needs a sarcasm emoticon. Way too many people get confused. Or perhaps we need a non-sarcasm emoticon and we just assume sarcasm by default.

  • (cs)

    Maybe I'm missing something here, but what about the vbCRLF constant?  Was that too obvious?

  • (cs)

    Its someone who has just discovered OO. Wow I could like "properly encapsulate" that in a class! And encapsulate that! In fact I wont add more than one method per level of inheritance.....

  • (cs) in reply to brandonh6k

    brandonh6k:
    Maybe I'm missing something here, but what about the vbCRLF constant?  Was that too obvious?

    This is C#. vbCrLf is only in VB. Hence the "vb" prefix. [:P]

    I suppose, however, he could have referenced Microsoft.VisualBasic.dll and used ControlChars.NewLine ...

  • (unregistered) in reply to phx

    Only thing worse would have been to make it a non static property.

     

  • (unregistered)

    I honestly wouldn't be that worried about cross-platform behavior... Especially in .NET.  What a waste of time.  It's almost like the person created it to show off their casting ability. 

  • (cs) in reply to Alex Papadimoulis
    Alex Papadimoulis:

    [image] brandonh6k wrote:
    Maybe I'm missing something here, but what about the vbCRLF constant?  Was that too obvious?

    This is C#. vbCrLf is only in VB. Hence the "vb" prefix. Stick out tongue

    I suppose, however, he could have referenced Microsoft.VisualBasic.dll and used ControlChars.NewLine ...

    Well, duh... [:$] I guess my brain is in neutral today.  I looked at it earlier and my brain said VB...  Too much coding with not enough caffeine today.

  • (cs) in reply to seizethedave

    seizethedave:
    Initech eh? (office space)

    Yea, I noticed that too. [8-|] Note the comment below the namespace

    //namespace changed to protect the guilty

     

  • (cs) in reply to redtetrahedron
    redtetrahedron:

    [image] seizethedave wrote:
    Initech eh? (office space)

    Yea, I noticed that too. [8-|] Note the comment below the namespace

    //namespace changed to protect the guilty

    I'm a lazy reader.

  • (unregistered)

    Have you tried Javascript? LOL

  • (cs) in reply to kentcb

    If this is to be sent over the wire (like HTTP) the standard says "CRLF", not "whatever your platform thinks is the end of a line". (Apparently there are actually broken web servers that will send bare CR's or LF's - why should clients have to deal with that?) And it's definitely better to make a constant than type "\r\n" all over the place, because if you accidentally type "\t\n" the compiler will catch it. So the only WTF here is the bizarre implementation - the concept is laudable.

  • (cs)

    It might be a WTF, but at least the code is working and doing exactly what is required. It returns a #13#10 as result. (You do know how to read Delphi code, do you? [:P])

  • (cs)

    This way he's protected in case the string delimeter characters ever change. ^_^

    (I couldn't resist. xD)

    This reminds me of XSLT; maybe the guy grew up there or in another language similarly restricted. XSLT's formatting is entirely implicit and generally implementation-defined - it works great for xml and html, when you don't care how the code looks, but it sucks for text out. So you have to define a newline to save yourself the burden of copy-pasting two long lines of code (!) every time, and whole functions just for each printf.

    XSL is a lot like Java. It started out as a quickie language to fill a void - quick, easy, and simple translation of XML into other things by a few web developers - but it spiraled into a general purpose language. Not being designed for it, it sucks. (I happen to think it's fun and still the best way to access XML, but procedural languages are finally catching up, thankfully.)

  • (unregistered) in reply to

    Indeed, "/r/n" is a lot better than the OP's solution. It's almost twice as good, since it uses 4 bytes instead of the pathetic 2.

  • (unregistered) in reply to
    :

    public static string CRLF = "/r/n";

    to me that's a lot cleaner...



    Indeed, "/r/n" is a lot better than the OP's solution. It's almost twice as good, since it uses 4 bytes instead of the pathetic 2.

  • (unregistered) in reply to

    Wow. It is \r\n, not /r/n.

  • (cs) in reply to Blue
    Blue:

    That is certainly ONE of them, in addition to the several which Alex mentioned in the intro post..

    So where's the triumphant "see, something horrible in a language other than VB!"?  Guess they won't stoop to "our" level.  Smile

     

     

  • (cs) in reply to Blue
    Blue:

    That is certainly ONE of them, in addition to the several which Alex mentioned in the intro post..

    So where's the triumphant "see, something horrible in a language other than VB!"?  Guess they won't stoop to "our" level.  Smile

     

     

  • (cs) in reply to Blue
    Blue:

    That is certainly ONE of them, in addition to the several which Alex mentioned in the intro post..

    So where's the triumphant "see, something horrible in a language other than VB!"?  Guess they won't stoop to "our" level.  Smile

     

     

  • (cs) in reply to aapopfriets

    Allright forum, you win. I give up trying to quote.

    "Note that this is still .NET,  so it's nothing like C/C++. Seeing as there are more C# WTFs than C/C++ WTFs, I state that C# == VB."

  • (cs) in reply to aapopfriets

    Someone here mentioned vbCrLf... actually you can use that in C# (kinda), by referencing the Microsoft.VisualBasic assembly and then using Microsoft.VisualBasic.ControlChars.CrLf.

    More to the point however, in all circumstances that I can think of, in C# a single \n will be seen as a line break. Unless you're writing a file in binary mode, you're not going to need \r\n. And even then there's the Environment.NewLine constant, which is automatically set to the correct character sequence for the platform.

  • (unregistered)

    Note that if someone's using "\r\n" they don't necessarily want Environment.NetLine - they might require CR-LF for a protocol, for example.

  • (cs) in reply to foxyshadis

    foxyshadis:
    This reminds me of XSLT; maybe the guy grew up there or in another language similarly restricted. XSLT's formatting is entirely implicit and generally implementation-defined - it works great for xml and html, when you don't care how the code looks, but it sucks for text out. So you have to define a newline to save yourself the burden of copy-pasting two long lines of code (!) every time, and whole functions just for each printf.

    XSL is a lot like Java. It started out as a quickie language to fill a void - quick, easy, and simple translation of XML into other things by a few web developers - but it spiraled into a general purpose language. Not being designed for it, it sucks. (I happen to think it's fun and still the best way to access XML, but procedural languages are finally catching up, thankfully.)

    If you're going to start dissing XSL, we'll need to go outside and have some words.

     Seriously, comparing XSL and Java? I've never heard of two things more different. The only thing they have in common is that ... because they... since they both... ummm...  they have absolutely nothing in common!

    C'mon now. If it's not designed for something you need, don't use it! pfft.

  • (unregistered) in reply to
    :
    Note that if someone's using "\r\n" they don't necessarily want Environment.NetLine - they might require CR-LF for a protocol, for example.


    Yeah, I've used vbCrLf a lot over the past week.

    A message must...end with a 'carriage return - line feed' (CRLF)...


    Underlines and bolds straight from the MODBUS specs.  Wouldn't a WTF in that case be using NewLine?
  • (cs) in reply to aapopfriets

    <FONT size=2>"Note that this is still .NET,  so it's nothing like C/C++. Seeing as there are more C# WTFs than C/C++ WTFs, I state that C# == VB."
    </FONT>

    <FONT size=2>Um... No.   I'd say this is clearly the work of a C programmer writing his first C# program.   Who else would cast an int to a char?</FONT>

     

  • (unregistered) in reply to seizethedave
  • (unregistered) in reply to
    :
    Have you tried Javascript? LOL

    genius
  • (unregistered)

    In defense of this code, I can think of one sensible reason for it: the original developer is an old Java developer.

    The problem is that "\n" doesn't mean 0x10.  It means "end-of-line."  Which means that if you compile "\n" on a platform that uses a different end-of-line character (read: Mac OS Classic), your code will not generate 0x10, but 0x13 instead (on Mac Classic, anyway, since \r and \n are swapped there).

    Consequently, if you're trying to write portable code that needs to work with binary internet protocols (such as SMTP, which requires 0x13 0x10 as a line terminator in some sections), you can not blindly use "\r\n", since it will fail in some locations.

    However, Mac Classic is virtually dead as a development platform, and I know of no other platform that doesn't follow the Windows/Unix line ending conventions, so this probably isn't an issue.

    Lack of portability of C# to a Mac is a non-starter; C# code can run on Mac OS X, through Mono and Portable.NET, though Mac OS X follows Unix line ending conventions, so "\r\n" should still be portable.

  • (unregistered)

    "Seriously, comparing XSL and Java? I've never heard of two things more different. The only thing they have in common is that ... because they... since they both... ummm...  they have absolutely nothing in common!"

    They're both turing complete.

  • (cs) in reply to JamesCurran
    JamesCurran:

    <font size="2">"Note that this is still .NET,  so it's nothing like C/C++. Seeing as there are more C# WTFs than C/C++ WTFs, I state that C# == VB."</font>

    <font size="2">Um... No.   I'd say this is clearly the work of a C programmer writing his first C# program.   Who else would cast an int to a char?</font>

     


    Any C programmer that thinks assigning 10 or 13 to a char needs a cast, is not a C programmer.

  • (unregistered)
    <FONT color=#808000 size=2>

    What ever happened to just using the framework

    [code language="c#"]<FONT color=#808000 size=2>
    

    System</FONT><FONT size=2>.</FONT><FONT color=#808000 size=2>Environment</FONT><FONT size=2>.</FONT><FONT color=#808000 size=2>NewLine</FONT>

    [/code]

    </FONT><FONT color=#808000 size=2>McGiv

    </FONT>
  • (unregistered)

    He could use the stringbuilder to concatenate the strCR and strLF

     

  • (cs)

    This is the most pathetic thread of comments I've ever seen at this site.  What a great idea, Environment.NewLine() ??  or "\r\n"  ???   Brilliant!  Alex, you should have thought of these and mentioned them in your initial post! 

  • (cs)

    <FONT style="BACKGROUND-COLOR: #efefef">BTW</FONT>

    <FONT style="BACKGROUND-COLOR: #efefef">"\r\n"</FONT>

    <FONT style="BACKGROUND-COLOR: #efefef">2 bytes, not 4 ;)</FONT>

  • (unregistered) in reply to phx
    phx:

    <FONT style="BACKGROUND-COLOR: #efefef">BTW</FONT>

    <FONT style="BACKGROUND-COLOR: #efefef">"\r\n"</FONT>

    <FONT style="BACKGROUND-COLOR: #efefef">2 bytes, not 4 ;)</FONT>

    Are you so sure those aren't Unicode characters?  [*-)]

  • (cs) in reply to Jeff S

    Re: "This is the most pathetic thread of comments I've ever seen at this site.  What a great idea, Environment.NewLine() ??  or "\r\n"  ???   Brilliant!  Alex, you should have thought of these and mentioned them in your initial post! "

    As opposed to the chock-full-o-content post you just made?

    Oops, I just did it too! [:P]

     

  • (cs) in reply to phx

    phx:
    BTW
    "\r\n"
    2 bytes, not 4 ;)

    ahem....

    First of all, "\r\n" is three bytes, not two (don't forget the terminating NUL)

    Second, the joke was the the original poster had written "/r/n" which really is four (well, five) bytes. Scroll back and finally have the laugh that the rest of us had a week ago.

  • (unregistered) in reply to phx
    phx:

    <font style="background-color: rgb(239, 239, 239);">BTW</font>

    <font style="background-color: rgb(239, 239, 239);">"\r\n"</font>

    <font style="background-color: rgb(239, 239, 239);">2 bytes, not 4 ;)</font>



    Well.. if your talking about the internal memory representation of this in .Net then it is 4 bytes with no null terminator when placed in a string vairable.  If your talking about the byte size of this piece of data as it gets written somewhere, this it is dependant on the character encoding (ASCII, UTF8, UTF16, etc).


Leave a comment on “A Constant ... Constant?”

Log In or post as a guest

Replying to comment #:

« Return to Article