I thought this will be a good forum to have some fun with an algorithm involving recursion and String manipulation. I was writing an Html unescape algorithm in Java today. What I came out with is the one below. There is a problem in the algorithm below that eats up some space or characters for some corner cases. Can you figure out what the problem is?
I wrote the class in a way so that you can compile and run it in command prompt and can see the output right away. You can do some trial and error and figure out the issue in the algorithm below. If you can please, let me know so that I know exactly where I am going wrong.
Few typos/mistakes are corrected, now your code looks as follows: and the output is:
Finally: Ashik's Quote <Test Ok = Ashik's Quote ><Test Ok
-----------
Finally: M& M > 5 = M& M > 5
-----------
Finally: M & M > 5 = M & M > 5
-----------
Finally: M &M > 5 = M &M > 5
-----------
Finally: M& M> 5 = M& M> 5
-----------
Also:
-->Apos'trophie & "quote" is <present>
-----------
Also:
-->Please check for empty space in Order Review tab.
-----------
Also:
-->Also check for Billing Information & Subscription Information & Order Review tabs.
-----------
Also:
-->It's difficult to check today's capitalization strategy for all tabs.
-----------
Also:
-->Remember that 12 is > 9 is > 4
-----------
Also:
-->Similarly 8 is < 10 is < 15
-----------
Also:
-->Shakespeare said,"To be or not to be that is the question."
-----------
Also:
-->Think & think about New York's <best pizza> as the "ultimate" pizza!
-----------
Also:
-->Apos'trophie & "quote" is <present>
-----------
I didn't get you what you are expecting the output to be?
I see the problem here. JavaRanch is converting or escaping the characters that I wanted to escape through coding. I thout the
I did not want to add the same character twice. Instead one of these two will be & # 6 0 ; and the other will be & l t ; (keeping space for each character but there will be so space and those should be treated as one string). Same for all the others.
I tried to attach the source code but the forum is not allowing .java, .htm, .txt, .abc extension files. So I don't know how I can attach the file itself.
By the way, I believe the problem in logic is around these 2 lines.
I am attaching 2 GIF images one by one that has the source code. I am not sure if it will be enough for understanding but it will show you the different between the code posted and what I actually wrote.
It would be much better if you posted properly indented code using CODE tags instead of posting screenshots - much more likely that people will actually read it.
Post by:autobot
I think I'll just lie down here for a second. And ponder this tiny ad:
a bit of art, as a gift, that will fit in a stocking