How to read special characters from HTML input AS special characters

Question!

I'm writing a barcode application whereby the user has the ability to specify a list of termination characters to be transmitted with each barcode. Consider the following:

<input id="terminators" type="text" value="\n" />

The trouble is when I retrieve the value from the input, the escape sequence \n is returned as two individual characters \ and n. Whereas I need it as one \n ASCII character 10.

You can reproduce this issue in your browsers console using the following code:

document.getElementById('terminators').value.charCodeAt(0) === '\n'.charCodeAt(0)



Answers

Figured it out with the help of some FB friends. The value of an input is escaped with an additional \, so \n becomes \\n:

We can validate this using the following test:

document.getElementById('terminators').value.charCodeAt(0) === '\\n'.charCodeAt(0)

https://jsfiddle.net/v9b348z3/



I will suggest to implement one constructor for unsigned long long it.

The reason is: execute below code. Code will not compile due to ambiguity.

Then remove the int constructor and build again. Now the code will compile and execute successfully.

#include <iostream>

class myClass {
    private:
        unsigned long long int words;

    public:

    myClass(int i)
    {
        std::cout<<"in Int constructor"<<std::endl;

    }

    myClass(long long int i)
    {

        std::cout<<"in long constructor"<<std::endl;
    }

};

int main()
{
    myClass m(10000000000);    

    return 0;   
}


You need a logical condition in the while. Perhaps

program.toUpperCase().equals("Y")
By : nicomp


This video can help you solving your question :)
By: admin