As I understand it is because of problem with encoding?
That may be correct. It also may be that the stuff you are trying to turn into a String is not text at all. In fact, if that is a raw network packet that you have sniffed, it is pretty much guaranteed that some of the packet (the IP/ICMP packet headers) won't be text.
What is the solution to this problem?
The solution is to understand what it is you are trying to decode and whether or not it is appropriate to decode it as if it was encoded text. If not, you need to decode / display it differently ... depending on what the relevant RFC says about the packets you are trying to display.