MCPcopy Create free account
hub / github.com/audacity/audacity / utf8_width_print

Function utf8_width_print

lib-src/sqlite/shell.c:570–590  ·  view source on GitHub ↗

** Output string zUtf to stream pOut as w characters. If w is negative, ** then right-justify the text. W is the width in UTF-8 characters, not ** in bytes. This is different from the %*.*s specification in printf ** since with %*.*s the width is measured in bytes, not characters. */

Source from the content-addressed store, hash-verified

568** since with %*.*s the width is measured in bytes, not characters.
569*/
570static void utf8_width_print(FILE *pOut, int w, const char *zUtf){
571 int i;
572 int n;
573 int aw = w<0 ? -w : w;
574 for(i=n=0; zUtf[i]; i++){
575 if( (zUtf[i]&0xc0)!=0x80 ){
576 n++;
577 if( n==aw ){
578 do{ i++; }while( (zUtf[i]&0xc0)==0x80 );
579 break;
580 }
581 }
582 }
583 if( n>=aw ){
584 utf8_printf(pOut, "%.*s", i, zUtf);
585 }else if( w<0 ){
586 utf8_printf(pOut, "%*s%s", aw-n, "", zUtf);
587 }else{
588 utf8_printf(pOut, "%s%*s", zUtf, aw-n, "");
589 }
590}
591
592
593/*

Callers 2

shell_callbackFunction · 0.85

Calls 1

utf8_printfFunction · 0.85

Tested by

no test coverage detected