Wednesday, October 21, 2009

Pintout Unicode of a String

I don't use this often but I run into the problem occasionally. For example an special character in a text from database broken XML when it is put into xml. The problem is I don't know what character is doing it. So I need to find the unicode and replace it.

This is how to do it:
def thatString="sdsdsd sd fsd fsd fsd fsd fsd s ->s sd fsdf sdf "
that.toCharArray().each{ch->
printf("%04X%n", (int)ch);
}


This will printout all the unicode of the string

No comments:

Post a Comment