Skip to content

Instantly share code, notes, and snippets.

@00001H
Created January 1, 2025 13:46
Show Gist options
  • Save 00001H/05e0a2d4e71604badc648367c2023926 to your computer and use it in GitHub Desktop.
Save 00001H/05e0a2d4e71604badc648367c2023926 to your computer and use it in GitHub Desktop.
Type in toki pona and it copies the UCSUR to your clipboard
import pyperclip
dic = [
("A","\U000F1900"),
("AKESI","\U000F1901"),
("ALA","\U000F1902"),
("ALASA","\U000F1903"),
("ALE","\U000F1904"),
("ANPA","\U000F1905"),
("ANTE","\U000F1906"),
("ANU","\U000F1907"),
("AWEN","\U000F1908"),
("E","\U000F1909"),
("EN","\U000F190A"),
("ESUN","\U000F190B"),
("IJO","\U000F190C"),
("IKE","\U000F190D"),
("ILO","\U000F190E"),
("INSA","\U000F190F"),
("JAKI","\U000F1910"),
("JAN","\U000F1911"),
("JELO","\U000F1912"),
("JO","\U000F1913"),
("KALA","\U000F1914"),
("KALAMA","\U000F1915"),
("KAMA","\U000F1916"),
("KASI","\U000F1917"),
("KEN","\U000F1918"),
("KEPEKEN","\U000F1919"),
("KILI","\U000F191A"),
("KIWEN","\U000F191B"),
("KO","\U000F191C"),
("KON","\U000F191D"),
("KULE","\U000F191E"),
("KULUPU","\U000F191F"),
("KUTE","\U000F1920"),
("LA","\U000F1921"),
("LAPE","\U000F1922"),
("LASO","\U000F1923"),
("LAWA","\U000F1924"),
("LEN","\U000F1925"),
("LETE","\U000F1926"),
("LI","\U000F1927"),
("LILI","\U000F1928"),
("LINJA","\U000F1929"),
("LIPU","\U000F192A"),
("LOJE","\U000F192B"),
("LON","\U000F192C"),
("LUKA","\U000F192D"),
("LUKIN","\U000F192E"),
("LUPA","\U000F192F"),
("MA","\U000F1930"),
("MAMA","\U000F1931"),
("MANI","\U000F1932"),
("MELI","\U000F1933"),
("MI","\U000F1934"),
("MIJE","\U000F1935"),
("MOKU","\U000F1936"),
("MOLI","\U000F1937"),
("MONSI","\U000F1938"),
("MU","\U000F1939"),
("MUN","\U000F193A"),
("MUSI","\U000F193B"),
("MUTE","\U000F193C"),
("NANPA","\U000F193D"),
("NASA","\U000F193E"),
("NASIN","\U000F193F"),
("NENA","\U000F1940"),
("NI","\U000F1941"),
("NIMI","\U000F1942"),
("NOKA","\U000F1943"),
("O","\U000F1944"),
("OLIN","\U000F1945"),
("ONA","\U000F1946"),
("OPEN","\U000F1947"),
("PAKALA","\U000F1948"),
("PALI","\U000F1949"),
("PALISA","\U000F194A"),
("PAN","\U000F194B"),
("PANA","\U000F194C"),
("PI","\U000F194D"),
("PILIN","\U000F194E"),
("PIMEJA","\U000F194F"),
("PINI","\U000F1950"),
("PIPI","\U000F1951"),
("POKA","\U000F1952"),
("POKI","\U000F1953"),
("PONA","\U000F1954"),
("PU","\U000F1955"),
("SAMA","\U000F1956"),
("SELI","\U000F1957"),
("SELO","\U000F1958"),
("SEME","\U000F1959"),
("SEWI","\U000F195A"),
("SIJELO","\U000F195B"),
("SIKE","\U000F195C"),
("SIN","\U000F195D"),
("SINA","\U000F195E"),
("SINPIN","\U000F195F"),
("SITELEN","\U000F1960"),
("SONA","\U000F1961"),
("SOWELI","\U000F1962"),
("SULI","\U000F1963"),
("SUNO","\U000F1964"),
("SUPA","\U000F1965"),
("SUWI","\U000F1966"),
("TAN","\U000F1967"),
("TASO","\U000F1968"),
("TAWA","\U000F1969"),
("TELO","\U000F196A"),
("TENPO","\U000F196B"),
("TOKI","\U000F196C"),
("TOMO","\U000F196D"),
("TU","\U000F196E"),
("UNPA","\U000F196F"),
("UTA","\U000F1970"),
("UTALA","\U000F1971"),
("WALO","\U000F1972"),
("WAN","\U000F1973"),
("WASO","\U000F1974"),
("WAWA","\U000F1975"),
("WEKA","\U000F1976"),
("WILE","\U000F1977"),
("NAMAKO","\U000F1978"),
("KIN","\U000F1979"),
("OKO","\U000F197A"),
("KIPISI","\U000F197B"),
("LEKO","\U000F197C"),
("MONSUTA","\U000F197D"),
("TONSI","\U000F197E"),
("JASIMA","\U000F197F"),
("KIJETESANTAKALU","\U000F1980"),
("SOKO","\U000F1981"),
("MESO","\U000F1982"),
("EPIKU","\U000F1983"),
("KOKOSILA","\U000F1984"),
("LANPAN","\U000F1985"),
("N","\U000F1986"),
("MISIKEKE","\U000F1987"),
("KU","\U000F1988"),
("PAKE","\U000F19A0"),
("APEJA","\U000F19A1"),
("MAJUNA","\U000F19A2"),
("POWE","\U000F19A3")
]
dic.sort(key=lambda p:len(p[0]),reverse=True)
sym = str.maketrans({
"(": "\U000F1990",
")": "\U000F1991",
"^": "\U000F1992",
#F1993 SITELEN PONA START OF LONG PI
"_": "\U000F1994",
"-": "\U000F1995",
"+": "\U000F1996",
"[": "\U000F1997",
"]": "\U000F1998",
"~": "\U000F1999",
"{": "\U000F199A",
"}": "\U000F199B",
".": "\U000F199C",
":": "\U000F199D"
})
while True:
stc = input().lower().translate(sym)
for k,v in dic:
stc = stc.replace(k.lower(),v)
pyperclip.copy(stc.replace(" ",""))
@00001H
Copy link
Author

00001H commented Jan 1, 2025

PS: START OF LONG PI is commented because it's deprecated in favor of the generic long glyph starter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment