Unicode character codes are UTF-8 encoded before being stored in memory. A lot of languages, like HTML, do the conversion for us and allow us to just use the Unicode character code. However, some assemblers and compilers don't do this out of the box and some teachers like making you do the conversions by hand.

I decided to make a quick tutorial on how to do the conversion by hand in case Unicode character codes are not enough for your assembler, compiler or teacher. I am assuming you have already had an introduction to this topic and just want to know how to do the actual conversion. Neither hexadecimal nor binary numbers are explicitly denoted but they are pretty easy to tell apart.

Find the character code you want to convert to hex. These codes are in hex but for any code bigger than `7F`

you will need to do an extra conversion to get the actual hex value.

- If it's between
`0`

and`7F`

then no conversion is necessary.`Z`

has the character code`005A`

so in hex it's simply`5A`

.

- Note: For anything above
`7F`

we need to convert the character code to binary first. - If it's between
`80`

and`07FF`

you convert the character code to binary, then simply use the template`110x`

`xxxx`

`10xx`

`xxxx`

and fill the binary number you got into the x's starting from the back.`Ä`

has the character code`00C4`

(or simply`C4`

), that's bigger than`7F`

so we convert it to binary and get`1100`

`0100`

.- Now we just fill it into our template from the back, this gives us
`1100`

`0011`

`1000`

`0100`

. - Note: our number didn't completely fill all the x's in the template and that's ok! We just set the remaining x's to
`0`

. - Now we can convert the binary number we got back to hex and we get
`C3 84`

.

- If it's between
`0800`

and`FFFF`

use the template`1110`

`xxxx`

`10xx`

`xxxx`

`10xx`

`xxxx`

. - If it's between
`10000`

and`10FFFF`

use the template`1111`

`0xxx`

`10xx`

`xxxx`

`10xx`

`xxxx`

`10xx`

`xxxx`

.

Quite simple, right?