Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

Delimiting 2 values

I am storing some values in a particular column in database table (database - MS SQLServer). The 2 values are delimited by #.
User is provided a text field, where he can enter values. When this form is submitted, then a value ispicked up from the session and the value entered by the user is appended to it (# delimiter is used) and stored in the database.

Now I have been suggested to use a tabulator character ("\t") instead, since it can never be entered by the user in the text field.

When I see the value in the database it shows a square type of character inplace of tabular character. I want to know it is the right way to do this stuff or should i recommend going back to "#". Also when I get that value from the database, how can I break them into their original form.
0
thomas908
Asked:
thomas908
  • 7
  • 6
  • 4
2 Solutions
 
objectsCommented:
the square most likely just means the font being used cannot diaplay it
to break it up use split:

String[] split = field.split("\\t");
0
 
CEHJCommented:
The first question is: why are you storing two values in one column?
0
 
thomas908Author Commented:
We are using a proprietory framework. Can't make any changes to the database.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
thomas908Author Commented:
Also when I retreive the value from the database it shows only 1 space instead of tabular space.
0
 
CEHJCommented:
For a separator, i would use a value that is unlikely to appear *ever* otherwise. Tab is far too common
0
 
thomas908Author Commented:
But user can never enter a tab in a text field. If he presses tab he will come to the next field.
0
 
objectsCommented:
> Also when I retreive the value from the database it shows only 1 space instead of tabular space.

depends on where you are displaying as to how much space. ie. how it displays tabs
but thats irrelevant to you isn't it, as you are just using it as a seperator.
0
 
CEHJCommented:
>>But user can never enter a tab in a text field.

Yes, but a tab could creep into the data in some other way. More importantly, it could creep *out* too
0
 
thomas908Author Commented:
>>depends on where you are displaying as to how much space. ie. how it displays tabs
>>but thats irrelevant to you isn't it, as you are just using it as a seperator.

What I am concerned about is that, as it is displaying a space instead of a tab, does it mean tab is truncated to a space.
What got into the database was

"a"+"\t"+"b"

So I was expecting from database

a      b

but what i am getting is
a b

Does this mean tab is truncated to space.
0
 
thomas908Author Commented:
>>
Do you mean user himself enter \t as a part of content. If so we can restrict that using javascript. Is there any other way it can creep in.
0
 
objectsCommented:
> What I am concerned about is that, as it is displaying a space instead of a tab, does it mean tab is truncated to a space.

doubt it.
splitting them asd I suggested above will confirm

>  Is there any other way it can creep in.

a tab is not going to creep in :)  and certainly no more than any other character.
you can check the fields before joining them if you want and either strip them or tell the user they can't enter it.
0
 
CEHJCommented:
Whitespace is often subjected to processing. IMO it's not a good candidate for a separator. Try

http://www.fileformat.info/info/unicode/char/001e/index.htm
0
 
thomas908Author Commented:
Sorry for my ignorance. I am unable to understand this document. can you please elaborate what this document is conveying?
0
 
objectsCommented:
Details of a different character you could use as a seperator.
Can't see that you'll have problems with using \t though, its quite often used as a seperattor.
And as you say it won't ever appear in the text.
0
 
CEHJCommented:
It's conveying information about a record separating character. All you need to know is its code
0
 
thomas908Author Commented:
Thats a lot objects and CEHJ
0
 
CEHJCommented:
:-)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 7
  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now