用于转义字符串的标准c库 [英] standard c library for escaping a string
本文介绍了用于转义字符串的标准c库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,如果我有C字符串:
char example [] =first line\\\
second line:\inner quotes\;
我想打印
first line\\\
second line:\inner quotes\
有没有一个库函数可以为我做这个转换?滚动我自己只是看起来有点愚蠢。
奖金积分,如果我可以给它一个长度逃脱(所以它停止之前或之后的
解决方案
如果您正在编写GPL内容,可以使用 http:// git。 savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/quotearg.c;hb=HEAD
Is there a standard C library function to escape C-strings?
For example, if I had the C string:
char example[] = "first line\nsecond line: \"inner quotes\"";
And I wanted to print
"first line\nsecond line: \"inner quotes\""
Is there a library function that will do that transformation for me? Rolling my own just seems a little silly.
Bonus points if I can give it a length to escape (so it stops before or beyond the \0
).
解决方案
If you were writing GPL stuff you might use http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/quotearg.c;hb=HEAD
这篇关于用于转义字符串的标准c库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文