Thanks Viktor,

Why not complete?
In order to send out to full printers and terminals may be useful.

HB_EXPORT char * hb_strRemEscSeq( char *str, ULONG *pLen )
{
  ULONG ul = *pLen, ulStripped = 0;
  char *ptr, *dst, ch;

  ptr = dst = str;
  while( ul )
  {
     if( *ptr == '\\' )
        break;
     ++ptr; ++dst;
     --ul;
  }

  while( ul-- )
  {
     ch = *ptr++;
     if( ch == '\\' )
     {
        ++ulStripped;
        if( ul )
        {
           ul--;
           ch = *ptr++;
           switch( ch )
           {
              case 'a': ch = '\a'; break;
              case 'b':
                 ch = '\b';
                 break;
              case 'f': ch = '\f'; break;
              case 'n':
                 ch = '\n';
                 break;
              case 'r':
                 ch = '\r';
                 break;
              case 't':
                 ch = '\t';
                 break;
              case 'v': ch = '\v'; break;
              case '0':
              case '1':
              case '2':
              case '3':
              case '4':
              case '5':
              case '6':
              case '7':
                 ch -= '0';
                 if( ul && *ptr >= '0' && *ptr <= '7' )
                 {
                    ch = ( ch << 3 ) | ( *ptr++ - '0' );
                    ++ulStripped;
                    if( --ul && *ptr >= '0' && *ptr <= '7' )
                    {
                       ch = ( ch << 3 ) | ( *ptr++ - '0' );
                       ++ulStripped;
                       --ul;
                    }
                 }
                 break;
              case 'x':
                 ch = 0;
                 while( ul )
                 {
                    if( *ptr >= '0' && *ptr <= '9' )
                       ch = ( ch << 4 ) | ( *ptr++ - '0' );
                    else if( *ptr >= 'A' && *ptr <= 'F' )
                       ch = ( ch << 4 ) | ( *ptr++ - 'A' + 10 );
                    else if( *ptr >= 'a' && *ptr <= 'f' )
                       ch = ( ch << 4 ) | ( *ptr++ - 'a' + 10 );
                    else
                       break;
                    ++ulStripped;
                    --ul;
                 }
                 break;
              default: /* case '\\': // Also any ch */
                 break;
           }
        }
        else
           break;

     }
     *dst++ = ch;
  }

  if( ulStripped )
  {
     *dst = '\0';
     *pLen -= ulStripped;
  }

  return str;
}

best regards
Xavi

Szakáts Viktor escribió:
2008-06-02 20:16 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
   * source/common/hbstr.c
     ! HB_EXPORT added to hb_strRemEscSeq(). Thanks Javier.
--
Brgds,
Viktor

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to