Skip to content

Instantly share code, notes, and snippets.

@osima
Created February 15, 2011 03:42
Show Gist options
  • Select an option

  • Save osima/827059 to your computer and use it in GitHub Desktop.

Select an option

Save osima/827059 to your computer and use it in GitHub Desktop.
// 数値参照を普通の文字に変換する
def convert = {
def r = it
if (it.indexOf("&#x") != -1){
def m2 = (it =~ /&#x(.+?);/)
if( m2.find() ){ r = (char) Integer.parseInt(m2.group(1), 16) }
}
else{
def m2 = (it =~ /&#(.+)?;/)
if( m2.find() ){ r = (char) Integer.parseInt(m2.group(1)) }
}
r
}
println convert('⇓')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment