Skip to content

Instantly share code, notes, and snippets.

@BarelyAliveMau5
BarelyAliveMau5 / modified_utf8.py
Last active November 15, 2024 07:58
python's version of java's modified utf8
# translated from: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/94cc251d0c45/src/share/npt/utf.c
def utf8s_to_utf8m(string):
"""
:param string: utf8 encoded string
:return: modified utf8 encoded string
"""
new_str = []
i = 0
while i < len(string):