Stylesheet taken-over/replaced by Chinese characters
Asked Answered
C

5

15

Okay, something just went crazy. Unless China is taking over starting with my test style.css file on my iepage - well I guess they are starting off on the right foot hating on IE, but anyways. It loads with no stylesheet - sad :( I go into the Web inspector and see that all my linked files are filled with [possibly] Chinese characters (瑨汭笠ऊ楷瑤...) I have tried deleting the files on the server and re-uploading them. The local files look fine and when loading the files directly they look fine. I didn't do anything that should of changed the rendering or anything either.

Cella answered 30/8, 2012 at 4:48 Comment(5)
Bizarre! And your jQuery library, it seems, has gone equally Asiatic... I'd guess it's a character encoding issue, but it could be that your server is compressing the files but not flagging them as compressed.Enchanting
I'm using Dreamhost as a server and I've never had any issue like this before. Nothing is set for compression at all. Update: contacted Dreamhost support to see if it is something on their end.Cella
I agree with @XavierHolt, that your files are compressed, but your server is not reporting that they are compressed, so the browser is trying to render them as if they were plain text.Religious
is actually Hindi character. LoL.Brannen
this happened to me because i renamed a .txt file as .html. copying the contents and pasting in a new .html file solved them problemRegurgitate
E
16

So I think I figured it out. This is weird. But anyway.

I copied and pasted your HTML to a local file to experiment with. And it loaded just fine. It was saved as UTF-8. Then I changed it to UTF-16, and I got exactly what you're seeing! As far as can tell, the browser (Firefox for Linux for me) is assuming the linked files are all in the same encoding as the HTML...

So - I assume the file on the server is in UTF-16, and if you change it to UTF-8 you should be good. Hope that fixes it!

PS: According to Firebug, your HTML is compressed by your server, even if you never explicitly told it to. But that doesn't seem to be causing any problems, thankfully.

Enchanting answered 30/8, 2012 at 5:13 Comment(4)
Oh, I understand what may have happened now. Coda asked me if I wanted UTF-8 or UTF-16 at some point when I was copying something. I chose the bigger number - bad choice. I have tried creating a new UTF-8 index.php file and pushing that to the server, but it didn't fit it. Is that what you were suggesting? Update: Also worth noting. I don't think this error happened until well after choosing UTF-18 and several edits and preview, but my memory could be wrong.Cella
@Cella - Hmm. That was indeed what I was suggesting. What do you mean "it didn't fit it"?Enchanting
@Cella - Oh. "fix" Man I can be dense sometimes... Anyway, this Google Groups post seems to explain how to reset your encoding. Is that what you tried?Enchanting
No I just changed the encoding within the app. However it appears to be working again - yay! I had to disabled/clear my cache. Thanks for the help I would have never figured this out myself.Cella
H
3

I encountered this same problem with XML files exported from PowerShell that were embedded in iFrames.

There was no issue in IE10/11 or Edge, but Firefox and Chrome wouldn't load the stylesheet.

The original page loading the iFrames was UTF8 encoded, same with the stylesheet. However, the XML file was exported to UTF16LE ("Unicode" in PowerShell). When the XML file was loaded from the iFrame, it loaded the stylesheet as Chinese characters.

I converted the encoding in PowerShell...

Get-Content C:\foldername\file.html -Encoding Unicode | Set-Content -Encoding UTF8 C:\foldername\file.html

...and it worked! My guess is that IE must treat the encoding of all files the same as the parent, which meant that the UTF16LE encoded file was rendered as UTF8. Chrome and Firefox apparently don't do that.

Thanks Xavier Holt for setting me on the right path!

Headship answered 29/10, 2015 at 17:25 Comment(1)
I just ran into this issue. I am using PowerShell ConvertTo-Html with the -CssUri. Chrome thought that my css file was unicode. Using Out-File -Encoding UTF8 fixed this when writing the HTML.Fructuous
D
0

Another quick solution is to change the file encoding using Notepad. Open the file in Notepad and Save As with the UTF-8 option selected from the drop down

enter image description here

Drayton answered 13/4, 2019 at 9:14 Comment(0)
R
0

it may be the .html file itself. I solved my similar problem by copying the contents of the original .html file and pasting it into a new file with the same name in the same directory (change the original's file name at first and delete the remainder of course)

Ratchet answered 6/5, 2022 at 20:10 Comment(0)
F
-1

Try this

link href="style.css" charset="UTF-8"

Forney answered 9/7 at 9:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.