Click here to Skip to main content
15,938,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have textbox for Title field on website. Some user had entered hexadecimal character (♂) which is vt(vertical tab - alt+11). On Website, this character was invisible, but when I copy pasted the text to notepad and notepad++, I could see this hexadecimal character.

My Query is why this character is not visible on website and what is the purpose of entering it?

In SQL server result also I can see this character.

My code is generating Excel from Datatable, and because of this character it is giving the error "hexadecimal value 0x0B, is an invalid character" while generating excel.

Thank you in Advance.
Posted
Updated 14-Oct-15 0:44am
v2

1 solution

That character is a C0 control code (Wikipedia[^]).

Quote:
Why this character is not visible on website
The HTML standard defines that these control codes must be ignored when rendering output. To show the corresponding symbols the equivalent Unicode symbols can be used (e.g. U+2642 for the male symbol ♂).

Quote:
What is the purpose of entering it
How such control codes are handled depends on the application. Some codes like line feed, carriage return and horizontal tab are used to format text. Others like ESC are mainly used during user input. The remaining ones are used by terminals, printers, and serial communication.

With HTML forms you should not allow that any of these characters can be entered (with some exceptions like multi-line edit fields which may except carriage return and horizontal tabs).
 
Share this answer
 
Comments
Priyanka_L 15-Oct-15 1:04am    
Hi Jochen. Thank you for the answer. As you said - The HTML standard defines that these control codes must be ignored when rendering output. But HTML can accept these kind of control codes , am I right? And when user had entered that character what he might have typed that he himself cant see it? Is it a possibility that this character might be entered by mistake?
Jochen Arndt 15-Oct-15 3:12am    
It depends on the type of your text box which might be a HTML form input field or script controlled. The content itself is not related to HTML (while the display is). So it might be that the user did not see what he entered (you can check it yourself with your form). He may have entered the character by mistake. But that is rather unlikely. Maybe he has copied and pasted the text.

As already noted you should add a validation function that shows a message when unsupported characters has been entered.
Priyanka_L 15-Oct-15 3:52am    
Thank you so much. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900