tags:

views:

89

answers:

2

Hello i just wander where can i find a tool that takes in my case java script string that is
unescape and converting it to escaped string so i could use it as string value in c++

for example characters like " i need to convert it to \"
i need something smart and not just replace all function .

+1  A: 

Notepad++ would do it well.

Menu TextFX > TextFX Characters > Escape... alt text

Michał Pękała
A: 

Pseudo code similar to C:

while(got_input_data)
{
    char = getFirstChar();
    if(char == '\"')
    {
        putchar('\');
        putchar('\"');
    }
    else if( another character that must be escaped )
    {
        // do similar stuff
    }
    else
    {
        // simply print the char that doesn't need to be escaped
        putchar(char);
    }
}

I don't know if such tools exist but I must admit that I wrote something similar when I needed to put a html page as a string in a CGI that was written in C. Old days ...

Iulian Şerbănoiu