Android Question String comparison

Ajay Kakar

Member
Licensed User
Longtime User
Dear Erel,

I am facing a very intriguing situation. I am passing a string parameter using the poststring method of the HTTPJOB object. I am passing a string "Endo motor". This string is compared with a field in an MDB file. The content of the field is also a string. When I compare with a record having a string "Endo motor" it gives a false. I am not able to do any comparison. I have checked the two strings, displayed them in my app, checked the length. All are the same. But in my ASP File the statement 'if mthread = rs("thread") then' returns a false. Does the parameter passed by the poststring method have some hidden characters which make the comparison return a false? I have an APP all completed except for this comparison which has had me stuck for over a couple of days. Would be great if you could shed some light.

Ajay
 

KMatle

Expert
Licensed User
Longtime User
Hm. I don't know asp but did you check if it's utf-8 encoded (or not). Are you able to display the values or replace it by a constant in you asp to check if the compare works generally?

I know this situations from php.
 
Upvote 0

Ajay Kakar

Member
Licensed User
Longtime User
Thanks Klaus.. I did check the ASP and it works fine when used directly. I used constants and it gives the desired output. I have not checked the utf-8 encoding. I have solved my problem in a roundabout way. I would prefer to use a much better technique. As I mentioned, the problem is that the spaces get eliminated when the string is passed to ASP. Before sending the string, I replaced all spaces with a constant value. The probability of this constant being used in the string is almost negligible. When i get the string in my ASP file, I replace the constant back with spaces and it works. I still am trying to find out why do the spaces get trimmed off when a string is passed by the POSTSTRING method.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
use

B4X:
if lcase(mthread) = lcase(rs("thread"))

to make sure the case matches (or lowercase the field in the query)
 
Upvote 0

Ajay Kakar

Member
Licensed User
Longtime User
Erel, the post string is deleting all spaces. I tried passing a variable string with the value "dental lab" and it becomes "dentallab". I tried sending a constant value "dental lab" and it becomes "dentallab". I have found a work around. I am inserting a constant value wherever I have a space and I reverse it in my ASP code. This is the only way I can get it to work. Either poststring takes away the spaces or ASP does not read the space (Chr(32)) sent by poststring.

The case is not the problem. It has been checked.

Ajay
 
Upvote 0
Top