| « Prev | Page 1 | Page 2 | Next » |
|
[:'(] Just another reason to cry! WTF is this dude thinking?
|
|
Initech eh? (office space)
|
|
I guess he thought the one-liner
return ((char)13).ToString() + ((char)10).ToString(); was too confoozing. ;-) |
|
Oh no, that guy is SOOO stupid; if he programs this way his app is not portable at all ! 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* |
|
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. [:)]
|
|
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? |
|
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. |
|
WoW! Now THAT is a good one!
|
|
public static string CRLF = "/r/n"; to me that's a lot cleaner... |
|
Tame your RSS you heathen.
|
|
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. |
|
Maybe I'm missing something here, but what about the vbCRLF constant? Was that too obvious?
|
|
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.....
|
Re: A Constant ... Constant?
2005-01-19 16:51
•
by
Alex Papadimoulis
|
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 ... |
|
Only thing worse would have been to make it a non static property.
|
|
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.
|
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. |
Re: A Constant ... Constant?
2005-01-19 17:29
•
by
redtetrahedron
|
Yea, I noticed that too. [8-|] Note the comment below the namespace //namespace changed to protect the guilty
|
I'm a lazy reader. |
Re: A Constant ... Constant?
2005-01-19 17:47
•
by
JoeNotCharles
|
|
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.
|
|
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])
|
|
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.) |
|
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.
|
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. |
|
Wow. It is \r\n, not /r/n.
|
|
|
|
|
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." |
|
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. |
|
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. |
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. |
Yeah, I've used vbCrLf a lot over the past week.
Underlines and bolds straight from the MODBUS specs. Wouldn't a WTF in that case be using NewLine? |
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?
|
genius |
|
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. |
|
"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. |
Any C programmer that thinks assigning 10 or 13 to a char needs a cast, is not a C programmer. |
|
What ever happened to just using the framework [code language="c#"] McGiv |
|
He could use the stringbuilder to concatenate the strCR and strLF
|
|
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!
|
|
BTW "\r\n" 2 bytes, not 4 ;) |
Are you so sure those aren't Unicode characters? [*-)] |
|
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]
|
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. |
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). |
| « Prev | Page 1 | Page 2 | Next » |