/ Check-in [255612f0]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Printing a value of 0 using %c terminates the string.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | printf-enhancement
Files: files | file ages | folders
SHA3-256:255612f0a131f2f522cbca3cc5a1edcf7e38938abca25ba421e7e38a422db9c9
User & Date: drh 2018-02-19 21:58:16
Context
2018-02-19
22:46
Enhance the string formatter (used by printf()) so that the width and precision of string substitution operators refer to characters instead of bytes when the alternate-form-2 flag ("!") is used. Also fix the %c substition to always work within unicode, regardless of the alternate-form-2 flag. check-in: c883c4d3 user: drh tags: trunk
21:58
Printing a value of 0 using %c terminates the string. Closed-Leaf check-in: 255612f0 user: drh tags: printf-enhancement
20:41
More test cases for unicode handling in printf. check-in: ac188211 user: drh tags: printf-enhancement
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/printf.c.

620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635


636
637
638
639
640
641
642
        buf[0] = '%';
        bufpt = buf;
        length = 1;
        break;
      case etCHARX:
        if( bArgList ){
          bufpt = getTextArg(pArgList);
          length = 0;
          if( bufpt ){
            buf[0] = c = *(bufpt++);
            length = 1;
            if( (c&0xc0)==0xc0 ){
              while( length<4 && (bufpt[0]&0xc0)==0x80 ){
                buf[length++] = *(bufpt++);
              }
            }


          }
        }else{
          unsigned int ch = va_arg(ap,unsigned int);
          if( ch<0x00080 ){
            buf[0] = ch & 0xff;
            length = 1;
          }else if( ch<0x00800 ){







|


<





>
>







620
621
622
623
624
625
626
627
628
629

630
631
632
633
634
635
636
637
638
639
640
641
642
643
        buf[0] = '%';
        bufpt = buf;
        length = 1;
        break;
      case etCHARX:
        if( bArgList ){
          bufpt = getTextArg(pArgList);
          length = 1;
          if( bufpt ){
            buf[0] = c = *(bufpt++);

            if( (c&0xc0)==0xc0 ){
              while( length<4 && (bufpt[0]&0xc0)==0x80 ){
                buf[length++] = *(bufpt++);
              }
            }
          }else{
            buf[0] = 0;
          }
        }else{
          unsigned int ch = va_arg(ap,unsigned int);
          if( ch<0x00080 ){
            buf[0] = ch & 0xff;
            length = 1;
          }else if( ch<0x00800 ){