print text to C-string
Last updated a year ago by lemon-clown .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install tocs 
SYNC missed versions from official npm registry.


npm install -g tocs

tocs is a command-tools, which type text-file to c-string. for example, if you have a file with content like:

// a.cpp
#include <cstdio>
using namespace std;

int main() {
    int T_T, A, B;
    scanf("%d", &T_T);
    for(int kase=1; kase <= T_T; ++kase) {
        scanf("%d%d", &A, &B);
        printf("%d\n", A+B);
    return 0;

and if you want post this in a json-format with tool like postman, it will be really annoy for the quotes.

and now, you could use tocs a.cpp --copy without any pain to get its something like:

"#include <cstdio>\r\nusing namespace std;\r\n\r\nint main() {\r\n    int T_T, A, B;\r\n    scanf(\"%d\", &T_T);\r\n    for(int kase=1; kase <= T_T; ++kase) {\r\n        scanf(\"%d%d\", &A, &B);\r\n        printf(\"%d\\n\", A+B);\r\n    }\r\n    return 0;\r\n}\r\n"


tocs <filename> [options]


  • -c, --copy: copy the result to your system-clipboard. Default value is false.
  • -C, --charset <charset>: specified file's encoding. Default value is utf-8.

Current Tags

  • 0.0.2                                ...           latest (a year ago)

2 Versions

  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 3
Dependencies (7)
Dev Dependencies (3)
Dependents (0)

Copyright 2014 - 2016 © |