same question in detail I posted in stackoverflow: div-innerhtml-string-after-null-character-ignored-in-webbrowser-control-but-not
The problem is that when setting string data which has a null in the middle, the succeeding characters after the null are not displayed in our custom browser using WebBrowser control, but IE8 was able to display all characters (it ignored the null).
Here's a sample script to replicate the issue:
Dim str
Sub Window_OnLoad()
str= "<TABLE >" & _
"<TR ><TD >0</TD></TR>" & _
"<TR ><TD >1" & chr(&H0) & "</TD></TR>" &_
"<TR ><TD >2</TD></TR><TR ><TD >3</TD></TR></TABLE>"
MsgBox str
document.all.mydiv.innerHtml = str
End Sub
(the "str" string contains a null character in the middle.)
Output (IE8):
0
1
2
3
Output (WebBrowser control):
0
1
In our application, the 2nd data retrieved (in the example above "1") that is set to the table element contains null after it, and what happens in the WebBrowser control is that the data after the null are discarded, thus not being able to print the whole data on the table. However, in IE8, it just seems to ignore the null and display the whole data on the table. Is there some way to make the WebBrowser control behave like in IE 8?
Solutions tried\Investigation results:
We already set the Browser Emulation correctly so that the web browser will behave like IE 8 but it still not working. (tried both 8000 and 8888)
We tried to use meta X-UA-Compatible instead of the Browser Emulation, but still not working. (tried both "IE=8" and "IE=EmulateIE8")
We tried setting all kinds of DOCTYPE but it also doesn't work.
In the sample code above I put a MsgBox to see the data to be set in the inner HTML and IE8 did not alert the data after the null. It was only able to ignore the null when setting it to the inner HTML. Could this be a special behavior of the inner HTML in IE?
I don't know if necessary but I tried to translate the code in javascript and still got the same results for both IE8 and WebBrowser control.
Tried to set User-Agent with the same as IE8 when navigating but the result is still the same (characters after null are discarded).