- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I want to see some real WTF's. Code that is so geniously insane or so utterly b0rken that it blows my mind. I want to see heisenbugs and mandelbugs.
Admin
Admin
Utterly tedious, both the original post and the comments on it. Do we really believe that anyone would write their own toUpperCase function? No, not really. Come on Alex, scrape the barrel a bit harder please.
Admin
trwtf is lower and upper case characters
Admin
Admin
Easy:
It exits from the loop as soon as it finds a match, so it's pretty much optimised. Only if you have a weird character set it might take a bit longer, but you can easily solve that by throwing in some extra hardware. This algorithm would be well suited for parallelisation, so imagine the sort of performance you could achieve on a Blue Gene/L.
Admin
Well, that's how it was in my memory, anyway...
Admin
Yea, another brilliant solution. Why is it that everyone thinks they have the magical solution to this issue that is better than any other possible solution? Why doesn't everyone realize the obvious that anyone in IT should readily understand... If you give 50 programmers a task, they're going to implement it in 50 different ways and they'll each think theirs is the best way.
BTW, the URL in your post returns a "Network Error (tcp_error)" error this morning. There's nothing like relying on an external resource in the constructor of an object that may or not be responding with the expected data. Frankly, I would love hung threads in an environment with a limited thread pool or the fact that this implementation just flat out wouldn't work if the data input can't be successfully retrieved.
Admin
The real WTF obviously is all the people on this board assuming an ASCII character set and even opposing UTF-8 as being "bullshit"
Admin
Init... cond... inc... looks like a job for the for loop!
Admin
All your solutions are inefficient according to my efficiency rules.
I am paid by the line, and the original solution outperforms your solutions 100:1 - or $100 to $1, to be more specific
Admin
And from the depths of COBOL...
000000 05 WS-LOWER PIC X(47) VALUE 000000 "abcdefghijklmnopqrstuvwxyzáàâäçéèêëíìîïóòôöúùûü". 000000 05 WS-UPPER PIC X(47) VALUE 000000 "ABCDEFGHIJKLMNOPQRSTUVWXYZÁÀÂÄÇÉÈÊËÍÌÎÏÓÒÔÖÚÙÛÜ".
000000 INSPECT STRING-NAME CONVERTING WS-LOWER 000000 TO WS-UPPER
Admin
I do believe that is the first D code I've seen here. Hopefully, I won't see any as the article content!
Admin
Kudos on the awesome nick tho.
Admin
In my company we really follow the true UNIX way: if there's a small, efficient tool we use it! Why reinvent the wheel if there's a tool doing already what's necessary?
We'd use some method to use the system (dependent on programming language, of course - .Net is preferred, Java is too old and not from a great company like MicroSoft (yes, we still use the old spelling)) to do sth. like echo "<insert string to convert here, preferred by string concatenation with the rest of the command line>" | tr '[a-z]' '[A-Z]' Use the resulting output as uppercased string.
You say: "That's not enough for non-english languages"? Well, that's their fault, not mine. I use the superior english language!
</TopCoderTraineeMode>Admin
Admin
Admin
I can see the original programmer thinking: "DAMN! I should have used case..."
(or switch, or whatever it is called in Java)
Admin
Admin
Well, I think I'm going The Long Way toUpper...
Admin
Too much circle-jerkery here. The topic is "The Long Way toUpper". There is a Short Way toUpper. Use It. All these digressions about "An Alternate Way toUpper, albeit more clever, but certainly No Less Bogus", is exceedingly tedious.
And the chap who wished cancer upon the family of his opponents in this pointless pissing contest seriously needs a vacation. Read: Professional Counseling.
Admin
That's a good start, but it's certainly not general (and therefore reusable) enough. I suggest:
Now we have immediate holistic-synergistic value-added network effects that are so important for leveraging empowering new paradigms in the successful enterprise. For instance, we can now rewrite that goofy modulus math as:
Admin
A worthy entry for the Blackholeth IOHCC. Chapeau!
Admin
Table lookup.
Admin
Oh god, please tell me that you are trolling. Failing that, please tell me that whatever code base you are working on doesn't do anything important.
Admin
Java is a Unicode beast and uppercasing unicode characters is a non-trivial exercise. There is no need to reverse-engineer it either, the source code as always been available.
Your comment should be tommorrow's WTF.
Admin
Yeah I agree with you. It's a waste of time even thinking about how to write code for this. The source code for doing this in the JDK is very complex, and impossible to understand unless you spend months studying Unicode. There are hundreds of special cases, and the classes are full of large data arrays, etc, etc.
The original WTF truly is a WTF and is on the same level as a programmer that types a for loop as Ctrl-C, Ctrl-V, Ctrl-V, Ctrl-V, Ctrl-V...etc. Almost total lack of knowledge on the language they are using.
Admin
The Java toUpperCase() method is truly 'the long way toUpper', especially since they call Character.toUpperCaseEx. I'm too lazy to decipher why they can't just iterate a char array and use that method, which could hold the various internationalization rules. An interesting WTF: 'the resulting String may be a different length than the original'
Admin
Admin
regardless if anyone cares about C or not, if I was to do such a function for my own use, it would look something like this, heck most C newbies would make something like this for lower to upper case conversion :P
yay for pointers :D
const char *upcase(char *var) { if(!var[0]) return "ERROR"; printf("given string = %s\n", var);
char *result = malloc(sizeof(var)); int delta = 'A' - 'a', i = 0;
for(; i < strlen(var); i++) { if(var[i] >= 'a' && var[i] <= 'z') result[i] = var[i] + delta; else result[i] = var[i]; //either not an alphabetic character or it's already upper cased } return result; }
Admin
Admin
I had this as an assignment for an intro level comp sci class. The answer was supposed to look like what i replied to looks like. However I was asked by several people to check theirs for correctness and sadly there was more than one guy whos result looked closer to what was posted in the article
Admin
Easy way to upper: loop through every character, and if its' ASCII value is between what, 64 and 90 (whatever the lower case range is), add 32 to it.
Admin
The obvious solution... in C because I don't know Java...
Simple! And no locale issues!
Admin
TRWTF is using a tree of
if
s when a switch statement would at least be slightly better