2

I've been having a glitch in my program for the last couple of hours in development. After some investigation, shows that one of my string variables apparently not what it says it is.

Lets take a look:

enter image description here

Now I did edit the photo so you could see the msgbox (which normally wouldn't appear until the next line, I wanted to show it directly next to the tip showing that cT = "dog").

Now, my cT variable is scrapped and read from a stream sent by a junk server I made. Is there a way to turn cT purely into what it says it is? It says it's "dog" but something tells me there are some hidden bytes in there or something not showing. Seeing as "dog" != "dog, does that make any sense?

Thanks for any help you can provide, at this point, I'm baffled. I'll probably go play some Portal.

edit: Portal just crashed, bad day I guess :/

edit, here is some code:

Dim cT As String = msg.Split("|")(4).Trim.ToLower
MsgBox(cT.Length)
Dim oct As String = Name.ToLower()
If StrConv(oct, VbStrConv.Lowercase).Contains(StrConv(cT, VbStrConv.Lowercase)) Then
    msend.nMessage(msg.Split("|")(2).Trim & " > All", msg.Split("|")(3))
End If

I'm using VB.net so all .net answers are acceptable.

14
  • Have you tried using String.Equals() (ie: cT.Equals("dog")) instead? Commented Sep 17, 2011 at 1:31
  • @NullUserException I'll try that now. RESULTS: Nope, actually it doesn't work that way either. Commented Sep 17, 2011 at 1:33
  • 1
    How about cT.Length = "dog".Length? Commented Sep 17, 2011 at 1:38
  • 2
    Did you check the encoding of the string to make sure that it's ASCII or UTF-8 because I've seen issues where reading from a stream that is sending characters in different encodings produces results like this Commented Sep 17, 2011 at 1:41
  • @Jesus Ramos, can you provide me with a way to convert it to one or the other so I can test that theory? Thanks. Commented Sep 17, 2011 at 1:43

2 Answers 2

2

There are probably some invisible characters like 13, 10, or 0 in cT. To see what is really in the string cT, use test code something like this:

For i = 0 To cT.Length - 1
  MsgBox(Asc(cT.Chars(i)))
Next i
Sign up to request clarification or add additional context in comments.

2 Comments

We've already determined that it does contain characters it shouldn't, how can I remove them?
They are probably characters < 32. If so, remove everything smaller than a value of 32.
2

Is there an embedded newline, backspace, or something funky? That can cause WYSI(not)WYG issues...

1 Comment

We've already determined that it does contain characters it shouldn't, how can I remove them?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.