Delimiting user input

What is the best character to restrict user input?

For example, if a user has an infinite number of text fields to type in, but each text field value will be concatenated into one database field, what is the safest character to delimit each input?

I think it must be a character not on your typical keyboard. Is there a character just for that?

+1


a source to share


6 answers


You can use one of the ASCII control characters. There's one called "Record Separator" which has a hexadecimal value of 0x1E which might suit your needs.

Edit . By the way, if you want to do the right job, you should probably make sure that \ x1E is escaped into user input. One way to do this is to use another ASCII escape character: \ x1B, which is the "escape" escape code. Thus, "\ x1E" becomes "\ x1B \ x1E" in the input, and "\ x1B" becomes "\ x1B \ x1B".



Keep in mind, of course, that since these are non-printable control codes, they cannot be displayed. If you want to print the view, you can go with a normal character like a comma and just avoid typing it.

+7


a source


I am guessing one approach is to use a comma and then remove the commas inside the user input. It is probably unsafe to assume that any character (or even a sequence of characters) cannot appear in user input - if you can enter it in your code, that is the way the user can enter it in a text field!



+3


a source


Typically, commas or semicolons are used to separate data. How about | which does the average user ever use ?

+1


a source


How about a keyboard shortcut? eg.

|::|

      

So

this|::|and|::|that. Plus Those:Here and there.|::|Even this|that works

      

0


a source


Any markup language will be used for this. They are a bit detailed, but at least they will be checking the future in the future.

0


a source


use & hearts; FTW

-1


a source







All Articles