So I am trying to read an escaped character from a file, It is a long and complicated process due to a lot of cleansing but that is all irrelevant. The end product is this property of an object -
props.inputSeperator: String type
Now this is a STRING. However, the value of this string in this specific case is \u0001
When I print this, the output is \u0001
. And the length of the string props.inputSeperator
is 6. How do I convert this string, into a string of a single character? Which would be the special character represented by \u0001
So the length of the string would be 1, and when printed, would print a single special character (\u0001
)
val x: String = "\u0001"
val s = Array("\\", "u", "0", "0", "0", "1").mkString("")
println(x) //prints "?" this is a SINGLE special character
println(s) //prints "\u0001"
I want to take s, and make it into the value of x essentially.