Thank you all for your help and feedback.
I finished the investigation and the conclusion is rather interesting…
The problem is in the CODE itself, NOT the data coming from the database!
This is how I proceeded to get to this conclusion:
1 - In all parts of the code of the webpage where it is supposed to sent data to the browser, I placed and Exception interceptor, something like this (the example below is a method in a custom WebListBox that takes a recordset and populates it):
[code]Public Sub Populate(rs as RecordSet)
Dim i_count As Integer
If ((rs = Nil) Or (rs.BOF AND rs.EOF)) Then
Self.DeleteAllRows
Return
End If
i_count = rs.FieldCount
while not rs.eof
Self.addRow “”// add a new row
for i as integer = 1 to i_count
Self.cell(self.lastIndex, i-1) = rs.idxField(i).stringValue.DefineEncoding(Encodings.UTF8)
next
rs.moveNext
wend
Exception err
Msgbox(“ALARM - ERROR IS HERE!”)
Break
End Sub
[/code]
2 - I also placed Break
at Session.UnhandledException
and App.UnhandledException
.
3 - I made several tests and the Exception ALWAYS bubbled up to Session.UnhandledException
. The exceptions scattered along the code where data was being sent to the screen were never fired.
After pulling a lot of hair and lose several hours of sleep, I remembered that the web app WAS working for almost a full year before presenting this “Encountered invalid character” issue. That made me think about it and I traced back what I did with the code that could have raised the issue. I had implemented several new features and streamlined code.
Nothing wrong there.
I also thought about adopting some code revision tool such as github (I looked into BitBucket actually). In order to make it work, I learned that the code should be saved as a “text file”, using the “Xojo Project” format in place of the “Xojo Binary Project” I’m used to. So I saved it and opened one of the resulting files with Notepad++ only to take a peek at it.
As this move to BitBucket is only a plan at this moment, I closed the file on Notepad++ and saved it back to “Xojo Binary Project” on the IDE. This is how I suspect code was contaminated with non-UTF8 characters… I might have changed something on Notepad++ before closing it.
In order to test my new hypothesis I saved the project as “Xojo Project” again, opened it on Notepad++ (again) and started looking for strange characters. Since the app is aimed at Brazilian users, which speak Portuguese, there are lots os opportunities for strange characters to appear, such as [, , , ] and so forth . Unfortunately the code is way to long to inspect… . The webpage that first raised the issue is about 8000 lines long on Notepad++. Not possible to inspect it manually, even using Notepad++ excellent search features.
I thought about writing a small desktop app using @Tim Streater’s idea, but that was not the fastest approach and I really don’t need computer forensics here (but the idea is cool!), so I decided instead to revert back to a previous code, implement the new features, review it and run on Debug mode.
And…
It ran smoothly…
So, I can conclude that the “invalid character” was in some label, title or any other part of the code that I might have messed with.
Any thoughts? Is that possible? Should I mark this as closed?