Transfer to MIPS
if (j < 0x80) {
// j fits in 7 bits expand to 8 bits
// n = j
} else if (j <= 0x7FF) {
// j fits in 11 bits expand to 16 bits
// b = low 6 bits of j
// a = next 5 bits of j
// n = 110 a 10 b
// 5 6 bits in
// j = aaaaa bbbbbb
// 3 5 2 6 bits out
// n = 110 aaaaa 10 bbbbbb
} else if (j <= 0xFFFF) {
// j fits in 16 bits expand to 24 bits
// c = low 6 bits of j
// b = next 6 bits of j
// a = next 4 bits of j
// n = 1110 a 10 b 10 c
// 4 6 6 bits in
// j = aaaa bbbbbb cccccc
// 4 4 2 6 2 6 bits out
// n = 1110 aaaa 10 bbbbbb 10 cccccc
} else if (j <= 0x10FFFF) {
// j fits in 21 bits expand to 32 bits
// d = low 6 bits of j
// c = next 6 bits of j
// b = next 6 bits of j
// a = next 3 bits of j
// n = 11110 a 10 b 10 c 10 d
// 3 6 6 6 bits in
// j = aaa bbbbbb cccccc dddddd
// 5 3 2 6 2 6 2 6 bits out
// n = 11110 aaa 10 bbbbbb 10 cccccc 10 dddddd
} else {
// j is outside the UTF-8 range of character codes
// n = 0xFFFFFFFF
}
See more in attatchment