Skip to content

Instantly share code, notes, and snippets.

@anhtran
anhtran / unicode_utils.py
Created April 18, 2018 05:41
Hàm số Chuyển đổi chuỗi Unicode Tổ Hợp sang Unicode Dựng Sẵn trong Python 3
def compound_unicode(unicode_str):
"""
Chuyển đổi chuỗi Unicode Tổ Hợp sang Unicode Dựng Sẵn
Edited from: `https://gist.github.com/redphx/9320735`
"""
unicode_str = unicode_str.replace("\u0065\u0309", "\u1EBB") # ẻ
unicode_str = unicode_str.replace("\u0065\u0301", "\u00E9") # é
unicode_str = unicode_str.replace("\u0065\u0300", "\u00E8") # è
unicode_str = unicode_str.replace("\u0065\u0323", "\u1EB9") # ẹ
unicode_str = unicode_str.replace("\u0065\u0303", "\u1EBD") # ẽ