I am stuck with an issue,i am fetching feeds from different social networking sites and displaying them somewhere while doing this few characters like <3 is converted to a heart symbol there are many other characters like smileys etc, so just wanna know what would be the best approach to handle these conversions in JAVA.
There probably is not a “best” way to do these things. You realise there are Unicode characters for smileys? This, for example, is \u263b: ☻ There are replacement methods in the String class. Have you tried them?
Yeah we can replace string with unicode character but that looks good if we are dealing with a single symbol/emoticon but how should be the design if we want to take care of multiple symbols/emoticons.
would just having a map of all the spl symbols and then checking for their presence in the messages and then replacing them would do??
You can put the symbols and their ASCII translations in a Map (as “V” and “K” respectively), yes. You might find you have to traverse the String and seek whether the String begins with all the “K”s at each character. Then you can append the character to a StringBuilder. Yes, it would work, but you are going to find that runs in O(m × n) complexity, which is rather like quadratic complexity.
You might not find a solution which has a lower complexity.