-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 My reply to Oren below.
from [email protected] Sent with Proton Mail secure email. On Monday, November 4th, 2024 at 23:24, [email protected] <[email protected]> wrote: Hi Oren, where did you come up with this sourcecode? > I don't know precisely what you're looking for but, here is some simple C > sourcecode that converts a unicode codepoint to a string in utf-8. > > > > > const char *u8ch_tostr(unsigned ch){ > > static unsigned char buf[5]; // every utf-8 character is <=4 bytes > > buf[4]=0; > > if(ch<0200){ // ascii is a subset of utf-8 > > buf[3]=ch; > > return buf+3; > > } > > if(ch<04000){ // characters under 0x7ff are 2 bytes > > buf[3]=(ch&077) + 0200; > > buf[2]=(ch/0100) + 0300; > > return buf+2; > > } > > if(ch<0200000){ // characters >= 0xFFFF are 3 bytes > > buf[3]=(ch&077) + 0200; > > buf[2]=(ch/0100&077) + 0200; > > buf[1]=(ch/010000) + 0340; > > return buf+1; > > } > > buf[3]=(ch&077) + 0200; // all other characters are 4 bytes > > buf[2]=(ch/0100&077) + 0200; > > buf[1]=(ch/010000&077) + 0200; > > buf[0]=(ch/01000000) + 0360; > > return buf; > > } > > --- > > Oren Watson (he/him) > > [email protected] > > -----BEGIN PGP SIGNATURE----- Version: ProtonMail wnUEARYKACcFgmcp6CkJkKkWZTlQrvKZFiEEZlQIBcAycZ2lO9z2qRZlOVCu 8pkAABN7AP9rJ8UQcdRkh9uAGaLHL8cQTZ5VCGGSit6NQrkn1+Fj8wEAtqih Z87XPWQmlkUErjqalF7UO2GkjtxwkRaTwl19IAA= =iIr1 -----END PGP SIGNATURE-----
publickey - [email protected] - 0x66540805.asc
Description: application/pgp-keys
publickey - [email protected] - 0x66540805.asc.sig
Description: PGP signature
