Re: FWD: Re: get the sourcecode [of UTF-8]

A bughunter via Unicode <[email protected]>
Newsgroups gmane.text.unicode.general
Message-ID <ZxfYTpjMrnozoyvF4EAUnUMB538tbiTU2I_LbvJSx8EwaNUpPRx_aknpzgslelVnOB57Bxj7KihNU7fi2M39iBLkFBkhvTn-Blxj_ccIqlM=@proton.me>
-----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 (application/pgp-keys, 653 B)
-----BEGIN PGP PUBLIC KEY BLOCK-----

xjMEZu0X1xYJKwYBBAHaRw8BAQdAH0I47jDsPZ6gvb+YUGBnAx7Jyf14AVOH
xa8y0+dmN5bNLUFfYnVnaHVudGVyQHByb3Rvbi5tZSA8QV9idWdodW50ZXJA
cHJvdG9uLm1lPsKMBBAWCgA+BYJm7RfXBAsJBwgJkKkWZTlQrvKZAxUICgQW
AAIBAhkBApsDAh4BFiEEZlQIBcAycZ2lO9z2qRZlOVCu8pkAAD9FAP9/ddT6
56Gka9NtMvmdoY5ktNgqbY5Xbd9fx6kPE5/4tQD/XiialKQHjmwAtbcSe1Q+
3cxYLxNhjU7mynQspv9dxADOOARm7RfXEgorBgEEAZdVAQUBAQdAnfp/z2Fw
RkpvUgf7mqYI9RKnTVadwGfgaQLhmwg3LxMDAQgHwngEGBYKACoFgmbtF9cJ
kKkWZTlQrvKZApsMFiEEZlQIBcAycZ2lO9z2qRZlOVCu8pkAAJi8AQC+fnOm
4Vj9QmH4H0GVt7RuOQK+wOQ1PRvpymSjeyBJOwD9GYuvxOAVK8iAupJ+ppwM
r36VukIe1pXuHo9RhjveAw0=
=FQFw
-----END PGP PUBLIC KEY BLOCK-----
publickey - [email protected] - 0x66540805.asc.sig (application/pgp-signature, 119 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.