hmmer-3.3/easel/esl_json.c
/* add_dirty_unicode()
 * Append a randomly chosen Unicode code unit to a growing UTF-8 encoded byte array
 * SRE, Tue 31 Jul 2018 [Hildur Gudnadottir, Rennur upp]
 *
 * Purpose:   Given byte array <s> currently of length <n> and allocated
 *            for at least 4 additional bytes; add a randomly chosen
 *            UTF-8 encoded Unicode code unit, using random number
 *            generator <rng>.
 *            
 *            The added code unit may consist of 1-4 bytes:
 *            1-byte units: any of the 95 printable ASCII char except \ or "
 *            2-byte unit:  \u00B5, $\mu$     (UTF-8 encoded: \xc2\xb5)
 *            3-byte unit:  \u221E, $\infty$  (UTF-8 encoded: \xe2\x88\x9e)
 *            4-byte unit:  \U000010083, Linear B 'horse' (\xf0\x90\x82\x83)
 *
 *            The number of bytes added is returned in <*ret_nadd>, and caller
 *            can use it to increment <n>.
 */
add_dirty_unicode()
Append a randomly chosen Unicode code unit to a growing UTF-8 encoded byte array
SRE, Tue 31 Jul 2018 [Hildur Gudnadottir, Rennur upp]

Given byte array  currently of length  and allocated
for at least 4 additional bytes; add a randomly chosen
UTF-8 encoded Unicode code unit, using random number
generator .



The number of bytes added is returned in <*ret_nadd>, and caller
can use it to increment .
add_dirty_unicode () Append a randomly chosen Unicode code unit to a growing UTF - 8 encoded byte array SRE Tue 31 Jul 2018 [ Hildur Gudnadottir Rennur upp ] Given byte array currently of length and allocated for at least 4 additional bytes ; add a randomly chosen UTF - 8 encoded Unicode code unit using random number generator . The number of bytes added is returned in < * ret_nadd > and caller can use it to increment .
static void
add_dirty_unicode(ESL_RANDOMNESS *rng, char *s, int n, int *ret_nadd)
{
  int roll = esl_rnd_Roll(rng, 100);
  int nadd;
  if      (roll < 85) { nadd = 1; do { s[n] = 32 + esl_rnd_Roll(rng, 95); } while (s[n] == '"' || s[n] == '\\'); }
  else if (roll < 90) { nadd = 2; s[n] = '\xc2'; s[n+1] = '\xb5';                                   }   
  else if (roll < 95) { nadd = 3; s[n] = '\xe2'; s[n+1] = '\x88'; s[n+2] = '\x9e';                  }   
  else                { nadd = 4; s[n] = '\xf0'; s[n+1] = '\x90'; s[n+2] = '\x82'; s[n+3] = '\x83'; }   
  *ret_nadd = nadd;
}
static void add_dirty_unicode ( ESL_RANDOMNESS * rng , char * s , int n , int * ret_nadd ) { int roll = esl_rnd_Roll ( rng , 100 ) ; int nadd ; if ( roll < 85 ) { nadd = 1 ; do { s [ n ] = 32 + esl_rnd_Roll ( rng , 95 ) ; } while ( s [ n ] == ' ' || s [ n ] == ' \\ ' ) ; } else if ( roll < 90 ) { nadd = 2 ; s [ n ] = ' \xc2 ' ; s [ n + 1 ] = ' \xb5 ' ; } else if ( roll < 95 ) { nadd = 3 ; s [ n ] = ' \xe2 ' ; s [ n + 1 ] = ' \x88 ' ; s [ n + 2 ] = ' \x9e ' ; } else { nadd = 4 ; s [ n ] = ' \xf0 ' ; s [ n + 1 ] = ' \x90 ' ; s [ n + 2 ] = ' \x82 ' ; s [ n + 3 ] = ' \x83 ' ; } * ret_nadd = nadd ; }
add_dirty_unicode()
 Append a randomly chosen Unicode code unit to a growing UTF-8 encoded byte array
 SRE, Tue 31 Jul 2018 [Hildur Gudnadottir, Rennur upp]
add_dirty_unicode () Append a randomly chosen Unicode code unit to a growing UTF - 8 encoded byte array SRE Tue 31 Jul 2018 [ Hildur Gudnadottir Rennur upp ]
// \mu // \infty // Linear B horse pictograph. RIP Alice Kober.