@@ -666,7 +666,7 @@ static bool _webui_check_certificate(const char* certificate_pem, const char* pr
666666#endif
667667#ifdef WEBUI_LOG
668668static void _webui_print_hex (const char * data , size_t len );
669- static void _webui_print_ascii (const char * data , size_t len );
669+ static void (const char * data , size_t len );
670670static int _webui_http_log (const struct mg_connection * client , const char * message );
671671#endif
672672static WEBUI_THREAD_SERVER_START ;
@@ -8847,13 +8847,15 @@ static void _webui_print_hex(const char* data, size_t len) {
88478847 }
88488848}
88498849static void _webui_print_ascii (const char * data , size_t len ) {
8850+ // This function is used to print the protocol binary packets. the packet
8851+ // may have ASCII and `0x00` inside text, as well as other non-ascii bytes
88508852 for (size_t i = 0 ; i < len ; i ++ ) {
8851- if ((unsigned char )* data == 0x00 ) {
8852- _webui_log_debug ("0x%02X" , 0xCF );
8853+ register unsigned char c = (unsigned char )* data ;
8854+ if (c == 0x00 ) {
8855+ _webui_log_debug ("%c" , 0xCF ); // Print `¤` | TODO: Maybe we can simply print a blank space?
88538856 } else {
8854- register unsigned char c = (unsigned char )* data ;
88558857 if (c < 32 || c > 126 ) {
8856- _webui_log_debug ("0x%02X" , c );
8858+ _webui_log_debug ("[ 0x%02X] " , c );
88578859 } else {
88588860 _webui_log_debug ("%c" , c );
88598861 }
0 commit comments