-
-
Save s9134131/72f4b7996492852f5b0b911fd0922e5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String convertDecimalNCRToString(String txt){ | |
Pattern p = Pattern.compile("&#(.*?);"); | |
Matcher m = p.matcher(txt); | |
while(m.find()){ | |
String match = m.group(1); | |
if(!match.startsWith("x")){ | |
txt = txt.replaceAll("&#" + m.group(1) + ";", "" + (char)Integer.parseInt(m.group(1))); | |
}else{ | |
txt = txt.replaceAll("&#" + m.group(1) + ";", "" + (char)Integer.parseInt(m.group(1).replaceFirst("x", ""), 16)); | |
} | |
} | |
return txt; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment