Skip to content

Instantly share code, notes, and snippets.

@mwleeds
Created March 10, 2021 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwleeds/31081036d3afe43d27d341a0711c6d1a to your computer and use it in GitHub Desktop.
Save mwleeds/31081036d3afe43d27d341a0711c6d1a to your computer and use it in GitHub Desktop.
#include <stdio.h>
/* copied from libsoup */
/* 00 URI_UNRESERVED
* 01 URI_PCT_ENCODED
* 02 URI_GEN_DELIMS
* 04 URI_SUB_DELIMS
* 08 HTTP_SEPARATOR
* 10 HTTP_CTL
*/
const char soup_char_attributes[] = {
/* 0x00 - 0x07 */
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
/* 0x08 - 0x0f */
0x11, 0x19, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
/* 0x10 - 0x17 */
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
/* 0x18 - 0x1f */
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
/* !"#$%&' */
0x09, 0x04, 0x09, 0x02, 0x04, 0x01, 0x04, 0x04,
/* ()*+,-./ */
0x0c, 0x0c, 0x04, 0x04, 0x0c, 0x00, 0x00, 0x0a,
/* 01234567 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* 89:;<=>? */
0x00, 0x00, 0x0a, 0x0c, 0x09, 0x0a, 0x09, 0x0a,
/* @ABCDEFG */
0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* HIJKLMNO */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* PQRSTUVW */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* XYZ[\]^_ */
0x00, 0x00, 0x00, 0x0a, 0x09, 0x0a, 0x01, 0x00,
/* `abcdefg */
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* hijklmno */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* pqrstuvw */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* xyz{|}~ */
0x00, 0x00, 0x00, 0x09, 0x01, 0x09, 0x00, 0x11,
/* 0x80 - 0xFF */
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
};
/* copied from GLib */
static const char acceptable[96] = {
/* A table of the ASCII chars from space (32) to DEL (127) */
/* ! " # $ % & ' ( ) * + , - . / */
0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C,
/* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x38,0x20,0x20,0x2C,0x20,0x20,
/* @ A B C D E F G H I J K L M N O */
0x38,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
/* P Q R S T U V W X Y Z [ \ ] ^ _ */
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x20,0x3F,
/* ` a b c d e f g h i j k l m n o */
0x20,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
/* p q r s t u v w x y z { | } ~ DEL */
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x3F,0x20
};
#define ACCEPTABLE(a) ((a)>=32 && (a)<128 && (acceptable[(a)-32] & 0x8))
int main(int argc, char **argv) {
for (int i = 0; i <= 0xFF; i++) {
if ((soup_char_attributes[i] & 0x07)) {
if (ACCEPTABLE(i))
continue;
if (i >= 0x20 && i <= 0x7E)
printf ("%#02X %c\n", i, (char)i);
else
printf ("%#02X\n", i);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment