How about replacing null with U+FEFF( zero-width non-breaking space) or U+2060( word joiner) before rendering?
Null character means "end of string" in traditional "null terminated string" using in C and other languages.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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:
How about replacing null with U+FEFF( zero-width non-breaking space) or U+2060( word joiner) before rendering?
Null character means "end of string" in traditional "null terminated string" using in C and other languages.
Hi KiyoshiNakano-3469,
You can try to add some js or modify the registry to use IE8.
More details you can refer to the following threads:
Webbrowser control behaving different than IE
Web Browser component is IE7 not IE8? How to change this?
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
If all else fails you can read the documentation.
https://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#text-0
It is abundantly clear from the documentation that html should NOT contain null characters. The fact that one browser does or does not display correctly today is not relevant, tomorrow none of them may. IMHO if you are doing anything but cleaning out the invalid characters you are making a mistake.