Closed Bug 79833 Opened 25 years ago Closed 22 years ago

XML:UTF8 characters are not displayed correctly in Page source

Categories

(Core :: XML, defect, P2)

defect

Tracking

()

RESOLVED WORKSFORME
Future

People

(Reporter: teruko, Assigned: hjtoi-bugzilla)

References

()

Details

(Keywords: intl)

Attachments

(3 files)

This XML page is written in UTF-8, but this does not have encoding declaration. Japanese characters are displayed correctly, but they are not displayed correctly in View|Page source. This may be related to the bug 41981. Tested 2001-05-08 build.
Changed QA contact to teruko@netscape.com and added intl keyword.
Keywords: intl
QA Contact: petersen → teruko
Frank, do you want to have this one? I see you fixed some other intl XML view source problem earlier...
Priority: -- → P3
Target Milestone: --- → mozilla1.0
Keywords: nsBranch
Keywords: nsBranchnsbranch+
Target Milestone: mozilla1.0 → mozilla0.9.4
nsBranch+ because this is pretty serious handicap for intl developers. Hoping the fix would be simple.
Priority: P3 → P2
This is actually a regression, view source works correctly in NS 6.1.
Status: NEW → ASSIGNED
Keywords: regression
Argh, this is bizarre! Occasionally things work, but usually they don't. I have seen working and broken behaviour both with NS 6.1 and the latest trunk builds. Removing regression keyword.
Keywords: regression
We have DetectByteOrderMark() that can autodetect some charsets, even if the encoding information is missing. Downloading the URL we get into that function, and see the first 4 bytes as: 3C 3F 78 6D. According to http://www.w3.org/TR/2000/REC-xml-20001006#sec-guessing the encoding information is required in that case. Without it, the DetectByteOrderMark() function does not detect the encoding at all. For normal XML view this happens to work correctly since UTF-8 is the default. But view source goes through HTML code path, which has a different default. Since DetectByteOrderMark() was not able to detect the encoding, we are left with the HTML default which shows the bug. The weird thing still remains: how does the view source SOMETIMES work correctly? Teruko, could you provide an additional testcase, which is basically the same as in URL but that has the encoding explicitly set to UTF-8? While debugging, I noticed that DetectByteOrderMark() is buggy and slow; I started fixing it, and will attach what I have done so far.
Heikki, I created the test case which you requested in http://babel/tests/browser/xml/xml-japan/weekly-utf8.xml View sourch works fine in the page.
Er, but now the original is gone? I need both, please, maybe named like: weekly-utf-8.xml - the original weekly-utf-8-with-encoding.xml - the one with encoding Also, what kind of program can I use to edit these files? Win2k Notepad displays the characters as "[]", and Visual C++ 6 as garbage, and saving the file from either one will change the byte order marks.
The charset of a html page is determined in /mozilla/content/html/document/src/nsHTMLDocument.cpp, function StartDocumentLoad(). I tried one testcase in view source, it did go along that code path. Yes, for html, the default normally is latin1, but user can change that. If your default is set to UTF8, or if you have some of the charset autodetector turn on, UTF8 will be detected. That might explained the bizzarre behavior you experienced. Hope those infor is helpful. Let me know if you have questions.
Adding perf keyword as well. DetectByteOrderMark() is called 22 times before the profile manager comes up, of which 18 times we actually end up in trying to detect the encoding. The numbers to bring up about:blank are 117 and 83, respectively. While detecting encoding, the current code first copies the buffer to a temp variable (usually a memory allocation needed since the buffer is so big), does a Cut() string operation and some unneeded comparisons etc. I believe I have now speeded up the encoding detection part quite a bit. There is no longer any string copying done, and no unneeded comparisons. It could perhaps be still made a bit faster by relying more on the allowed form and bit operations. I'll try to check what Quantify has to say. Needless to say, I am still trying to track down why things sometimes work without the encoding and sometimes not. Btw, Teruko, the encoding sample has different byte order marks from the original. I finally tried editing with Emacs, and it preserves the byte order marks so now I can twiddle with my local testcase as well. I will attach the current patch.
Keywords: perf
Moving. My understanding of the spec is that this could actually be a WONTFIX, but I really would like to know why things occasionally work. Putting explicit encoding in the XML declaration is always correct and in the testcase I believe it is even required per the spec because the first 4 bytes are "3C 3F 78 6D".
Keywords: nsbranch+
Target Milestone: mozilla0.9.4 → mozilla0.9.5
Target Milestone: mozilla0.9.5 → mozilla0.9.6
Target Milestone: mozilla0.9.6 → mozilla0.9.7
The perf patch has landed, removing keyword. As to the actual bug, I understand the testcase was incorrect (always requiring encoding in which case we do the right thing). The weird thing is when it is not present and things sometimes work and sometimes they don't work. Minor issue, so moving to future.
Keywords: perf
Target Milestone: mozilla0.9.7 → Future
Blocks: 187812
This worksforme now that view-source defaults to the charset of the page you opened it from....
Status: ASSIGNED → RESOLVED
Closed: 22 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: