mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-09-08 11:19:59 +00:00
config: Add UNITY_IS_PRINTABLE_CHAR function macro
This allows other charsets, such as UTF-8, to be printed properly without escaping.
This commit is contained in:
@@ -250,4 +250,12 @@
|
||||
*/
|
||||
/* #define UNITY_INCLUDE_EXEC_TIME */
|
||||
|
||||
/* Define this macro to redefine what the UnityPrintChar() function considers
|
||||
* a printable character.
|
||||
*
|
||||
* Example, for printing UTF-8:
|
||||
* #define UNITY_IS_PRINTABLE_CHAR(c) ((128 <= (c)) && ((c) <= 255))
|
||||
*/
|
||||
/* #define UNITY_IS_PRINTABLE_CHAR(c) ((32 <= (c)) && ((c) <= 126)) */
|
||||
|
||||
#endif /* UNITY_CONFIG_H */
|
||||
|
||||
+9
-1
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "unity.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef UNITY_PROGMEM
|
||||
#define UNITY_PROGMEM
|
||||
#endif
|
||||
@@ -88,8 +90,14 @@ static const char UNITY_PROGMEM UnityStrDetail2Name[] = " " UNITY_DET
|
||||
/* Local helper function to print characters. */
|
||||
static void UnityPrintChar(const char* pch)
|
||||
{
|
||||
#ifdef UNITY_IS_PRINTABLE_CHAR
|
||||
const bool isPrintable = UNITY_IS_PRINTABLE_CHAR(*pch);
|
||||
#else
|
||||
const bool isPrintable = ((32 <= *pch) && (*pch <= 126));
|
||||
#endif // UNITY_IS_PRINTABLE_CHAR
|
||||
|
||||
/* printable characters plus CR & LF are printed */
|
||||
if ((*pch <= 126) && (*pch >= 32))
|
||||
if (isPrintable)
|
||||
{
|
||||
UNITY_OUTPUT_CHAR(*pch);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user