Skip to content

Commit

Permalink
Create convertUnicode.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbeiji authored Mar 2, 2023
1 parent d8d37fe commit 839d196
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions convertUnicode.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fun main() {
while (true) {
println("Enter a hex value for a unicode character (e.g. 5B89):")
val unicodeHexValue = readLine()
if (unicodeHexValue?.isEmpty() == true) {
println("We're done here.")
break
}
println("The unicode value for $unicodeHexValue is ${
convertUnicodeHexToCharacter(unicodeHexValue!! )
}")
}
}

fun convertUnicodeHexToCharacter(hex: String): String {
val decimal = Integer.parseInt(hex, 16)
return Character.toString(decimal)
}

0 comments on commit 839d196

Please sign in to comment.