From 839d196eda3060c0b8611d209e4e5927316d66f1 Mon Sep 17 00:00:00 2001 From: Joe Lewis Date: Thu, 2 Mar 2023 10:36:58 -0800 Subject: [PATCH] Create convertUnicode.kt --- convertUnicode.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 convertUnicode.kt diff --git a/convertUnicode.kt b/convertUnicode.kt new file mode 100644 index 0000000..9b10cdc --- /dev/null +++ b/convertUnicode.kt @@ -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) +}