Let's say that I have a string: "\\u2026". And, I want it to change that to "\u2026" to print out the unicode in Scala. Is there a way to do that? Thank you for your time.
Edit: Let me clarify. Due to some circumstances, I have a string like: "Following char is in unicode: \\u2026", which prints:
Following char is in unicode: \u2026
But, I want to edit it so that it prints:
Following char is in unicode: …
Thank you for the answers. This is what I ended up doing.
def FixString(string: String) : String = {
var newString = string;
// Find the 1st problematic string
var start = string.indexOf("\\u");
while(start != -1) {
// Extract the problematic string
val end = start + 6;
val wrongString = string.substring(start,end);
// Convert to unicode
val hexCode = wrongString.substring(2);
val intCode = Integer.parseInt(hexCode, 16);
val finalString = new String(Character.toChars(intCode));
// Replace
newString = string.replace(wrongString,finalString);
// Find next problematic string
start = string.indexOf("\\u", end);
}
return newString;
}