C语言字符转义判断函数 - need_escape()详解
// 判断字符 c 是否需要进行转义 static int need_escape(char c) { switch (c) { case '': // 反斜杠 case ''': // 双引号 case '\b': // 退格 case '\n': // 换行 case '\r': // 回车 case '\t': // 制表符 case '\f': // 换页 return 1; case DEL: // ASCII 码为 127 的字符 -> \u007f return 5; default: if (c > 0 && c < ' ') { // ASCII 码为 1-31 的字符 -> \u00xx return 5; } return 0; } }
原文地址: https://www.cveoy.top/t/topic/oLk7 著作权归作者所有。请勿转载和采集!