MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / utf8_width_print

Function utf8_width_print

modules/dasSQLITE/sqlite/shell.c:676–697  ·  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

674** since with %*.*s the width is measured in bytes, not characters.
675*/
676static void utf8_width_print(FILE *pOut, int w, const char *zUtf){
677 int i;
678 int n;
679 int aw = w<0 ? -w : w;
680 if( zUtf==0 ) zUtf = "";
681 for(i=n=0; zUtf[i]; i++){
682 if( (zUtf[i]&0xc0)!=0x80 ){
683 n++;
684 if( n==aw ){
685 do{ i++; }while( (zUtf[i]&0xc0)==0x80 );
686 break;
687 }
688 }
689 }
690 if( n>=aw ){
691 utf8_printf(pOut, "%.*s", i, zUtf);
692 }else if( w<0 ){
693 utf8_printf(pOut, "%*s%s", aw-n, "", zUtf);
694 }else{
695 utf8_printf(pOut, "%s%*s", zUtf, aw-n, "");
696 }
697}
698
699
700/*

Callers 2

shell_callbackFunction · 0.85

Calls 1

utf8_printfFunction · 0.85

Tested by

no test coverage detected