As a test, I've generated some ASN.1 and C. Unfortunately, asn1c gives an error for PER encoding with this but not for BER encoding :-(
FooBar {1 2 3 4 5 6} DEFINITIONS ::=
 BEGIN
   Integer5 ::= INTEGER (-1..MAX)
   value1 Integer5 ::= 4096
 END
#include ?stdio.h>   /* for stdout */
#include  ?stdlib.h> /* for malloc () */
#include  ?assert.h> /* for run-time control */
#include ?integer5.h> /* Integer5 ASN.1 type */
/*
* This is a custom function which writes the
* encoded output into some FILE stream.
*/
static int
write_out(const void *buffer, size_t size, void *app_key) {
    FILE *out_fp = app_key;
    size_t wrote;
    wrote = fwrite(buffer, 1, size, out_fp);
    return (wrote == size) ? 0 : -1;
}
int main(int ac, char **av) {
 
 /* Encoder return value */
 asn_enc_rval_t ec;
 
 
 /* Declare a pointer to a Integer5 type */
 Integer5_t *integer5;
 
 /* Allocate an instance of  Integer5 */
 integer5 = calloc(1, sizeof(Integer5_t)); /* not malloc! */
 assert(integer5); /* Assume infinite memory */
 
 (*integer5) = 4097;
 
 if(ac < filename =" av[1];" fp =" fopen(filename," ec =" uper_encode(&asn_DEF_Integer5,integer5,write_out,fp);" encoded ="="">name : "unknown");
      exit(65); /* better, EX_DATAERR */
      } else {
      fprintf(stderr,"Created %s with PER encoded Integer5\n",filename);
      }
      fclose(fp);
 }
 /* Also print the constructed ???? XER encoded (XML) */
 xer_fprint(stdout,&asn_DEF_Integer5,integer5);
 return 0; /* Encoding finished successfully */
}
We may need this:
dom@heisenberg:~/asn15/asn1> darcs whatsnew
{
hunk ./UnitTest.lhs 33
+import qualified Data.Binary.Strict.Util   as BU
+
+bar = BU.hexDump
+bax = BU.hexDumpString
}