添加中文注释static int need_escapechar c switch c case case case b case n case r case t case f return 1; case DEL - u007f return 5; default if c 0 && c
// 判断字符 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/hiww 著作权归作者所有。请勿转载和采集!