Created
December 29, 2023 06:25
-
-
Save petergi/9be29180d6b7aa1e776a20f9377062eb to your computer and use it in GitHub Desktop.
Convert hex to ASCII
This file contains hidden or 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
let asciiValue: String = "1234567890ABCDEFGHIJ" | |
func asciiToHex(_ asciiValue: String) -> String { | |
let chars: [String.Element] = Array(asciiValue) | |
var hex: String = "" | |
for char: String.Element in chars { | |
hex += String(char.asciiValue!, radix: 16) | |
} | |
return hex | |
} | |
let result = asciiToHex(asciiValue) | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment