### Example – Encode string “₹” to UTF8 hexadecimal. (UTF8 Encode)

- Search for “₹” or rupee sign code point, which is
**“U+20B9”**

2. Convert **“20B9”** hexadecimal to binary numbers

Hexadecimal | Binary |
---|

2 | 0010 |

0 | 0000 |

B | 1011 |

9 | 1001 |

"20B9" = "0010 0000 1011 1001"

3. Refer to Table UTF8 Code Point Prefix, Binary 16 bits need 3 bytes format below.

Code Point 16 Bits = "1110(XXXX) 10(XXXXXX) 10(XXXXXX)"

Start to rearrange bits from the left-hand side of previous binary 16 bits as UTF8 encoding format.

Rearrange: 0010 0000 1011 1001 -> 0010 000010 111001

Put prefix binary in each byte to rearrange formatted.

UTF8 Prefix: "1110(0010) 10(000010) 10(111001)"

4. Now, you will get 3 bytes of UTF8 binary. Convert all binary back to hexadecimal.

Binary | Hexadecimal |
---|

11100010 | E2 |

10000010 | 82 |

10111001 | B9 |

The result of “₹” UTF8 encoding will be

Hexadecimal : E2 82 B9
Hex notation : \xE2\x82\xB9