πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #224386

My headers contain β€œ encoded-words ” ( UTF-8 via 7-bit ASCII ) ..

#224386
From: Jeffβ–²Relf
Date: Thu, 07 Aug 2008 02:26
74 lines
4224 bytes
Continuing where you left off, β€œ Tools.ietf.ORG/html/rfc2822 ” says:
β€œ Note: As was stated earlier, there are other standards documents,
  specifically the MIME documents [ RFC2045, RFC2046, RFC2048, RFC2049 ]
  that extend this standard 
  to allow for different sorts of message bodies.
  
  Again, these mechanisms are beyond the scope of this document. ”.

My headers contain β€œ encoded-words ” ( UTF-8 via 7-bit ASCII ),
RFC-2047 ( Tools.ietf.ORG/html/rfc2047 ) says:

β€œ Generally, an β€˜ encoded-word ’ is 
  a sequence of printable ASCII characters that begins with β€˜ =? ’,
  ends with β€˜ ?= ’, and has two β€˜ ? ’s in between.
  
  It specifies a character set and an encoding method, and
  also includes the original text encoded as graphic ASCII characters,
  according to the rules for that encoding method. ”.

β€œ MIME, redefines the format of messages to allow for:

  1. textual message bodies in character sets other than US-ASCII,
  2. an extensible set of different formats
     for non-textual message bodies,
  3. multi-part message bodies, and
  4. textual header information in character sets other than US-ASCII. ”

I wont' show you how X.CPP ( VC++ 9, in: JeffRelf.F-M.FM/X.ZIP )
encodes words, but this gives you an idea of how it decodes words:

Eval_inLineCharSet( LnP B, LnP E ) {

  LnP  P = B ;  int  Ch, Ch2 ;  if ( ! E )  E = B + StrLen( B );
  =?:  While( Ch != '=' || Ch2 != '?' );
  if ( ! Ch )  return ;  LnP  Funky = P ;  P += 2 ;
  
  While( Iden( Ch ) || Ch == '-' );  if ( ! Ch )  return ;

  if ( ! EqiN( P, L"?Q?", 3 ) &&  ! EqiN( P, L"?B?", 3 ) )  goto =?;
  LnP CP = Funky + 2 ;  int Len = P - CP ;
  if ( Len + 1 > 88 )  return ;
  
  wmemmove(  CharSet, CP, Len );  CharSet [ Len ] = 0 ;
  MIMECSETINFO __CharSet ;   FndCS( __CharSet )
  int Q = EqiN( P, L"?Q?", 3 );  P += 3 ;
  
  uchar  B_Line [ 400 ] = {};
  _LnP _P = B_Line - 1 ;  uint X = 0, By = 0, Cnt = 0 ;
  
  While ( Ch && ! ( Ch == '?' && Ch2 == '=' ) ) {
  
    if ( 4 + _P - B_Line >= 400 ) return ;
    if ( Q ) {  int  Hex, Hex2 ;
    
      if ( Ch != '=' || ( Hex = HexToN( Ch2 ) ) < 0
      || ( Hex2 = HexToN( P [ 2 ] ) ) < 0 )
        * ++ _P = Ch == '_' ? 32 : Ch ; 
      else * ++ _P = Hex * 16 + Hex2, P += 2 ;  }
      
    else if ( Ch > 32 && Ch <= 'z' ) {  X <<= 6 ;  X |= A_63 [ Ch ];
    
      if ( Ch != '=' ) By ++ ;  
      if ( ++ Cnt < 4 ) continue;   _LnP  XP = ( _LnP ) & X ;  XP += 3 ;
      Loop( By * 6 / 8 )  * ++ _P =  * -- XP ;   X = By = Cnt = 0 ;  } }
      
  * ++ _P = 0 ;  if ( Ch )  P += 2 ;  int  Sz_Was = P - Funky ;
  int Sz_Is = MultiByteToWideChar(
      __CharSet.uiInternetEncoding
    , 0, ( char * ) B_Line, -1, Funky, Sz_Was ) - 1 ;
    
  int UnUsed =  Sz_Was - Sz_Is ;  Funky [ Sz_Is ] = 0 ;  
  wmemmove( Funky + Sz_Is, P, E - P + 1 );
  if ( Ch )  Eval_inLineCharSet( Funky + Sz_Is, E - UnUsed );  }
Technical Details
Message-ID: <Jeff_Relf@Seattle.2008_Aug.6|7.26pm|p>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <48989017$0$99248$dbd4d001@news.wanadoo.nl> <Jeff_Relf@Seattle.2008_Aug.5|4.50pm|O> <4899b230$0$579$dbd41001@news.wanadoo.nl> <Jeff_Relf@Seattle.2008_Aug.6|2.10pm|b> <20080807082535.472@usenet.piggo.com> <20080807085448.403@usenet.piggo.com>

Show Full Headers
Complete Article Headers
Message-ID: <Jeff_Relf@Seattle.2008_Aug.6|7.26pm|p>
Subject: My headers contain β€œ encoded-words ” ( UTF-8 via 7-bit ASCII ) ..
Date: Thu, 07 Aug 2008 02:26:47 +0000
From: Jeffβ–²Relf <Jeff_Relf@Seattle.Invalid>
References: <48989017$0$99248$dbd4d001@news.wanadoo.nl> <Jeff_Relf@Seattle.2008_Aug.5|4.50pm|O> <4899b230$0$579$dbd41001@news.wanadoo.nl> <Jeff_Relf@Seattle.2008_Aug.6|2.10pm|b> <20080807082535.472@usenet.piggo.com> <20080807085448.403@usenet.piggo.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
Newsgroups: news.software.readers
Lines: 74
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net b5BGZGFsl/rEGzybJPX0VA0hBYPgF5PDNrbblTYJk136ULIrKB
Cancel-Lock: sha1:uzfwmOvM4WitpSC83rSAaWnrggA=
User-Agent: JeffRelf.F-M.FM/X.ZIP