11:34 AM
0
Q: Javascript Charset problem

CataI want to read a file from my server with javascript and display it's content in a html page. The file is in ANSI charset, and it has romanian characters.. I want to display those characters in the way they are :D not in different black symbols.. So I think my problem is the charset.. I have a...

 
What Content-Type header do you use with that file?
 
well in the text editor is ansi :D if that is the question :D, is not a html page it has just text :D
I tried "text/html; charset=UTF-8" but it's the same :D
 
@Cata: It is irrelevant what your text editor does. The only relevant thing is what Content-Type header the web server returns for that particular file.
 
@Tomalak: it seems to be ISO-8859-1 the charset :D, i took it from firefox :)
 
@Cata: Can you confirm that this is that the charset declaration that you also see if you load the file on its own?
 
11:35 AM
hello, thank you for your time Tomalak
 
Hi there
 
yes the pages have the same format now :D
 
What do you mean by format?
 
this is the content page: serialepreferate.ro/dexter202.srt
 
looks good, wait a sec
 
11:36 AM
and this is the page that results from the request : serialepreferate.ro/tralala.html
the last one is with the problems :D
 
The text file (dexter202.srt) is sent as Content-Type:text/plain
this is the problem
 
hmm
how can I fix this?
 
It should be sent as text/plain; Charset=Windows-1252 (probably)
You tell your web server to use a different Content-Type header for these files
 
I have a host, and I don't think that I can do that :D
is there another way?
 
You save your file not as ANSI, but as UTF-8
 
11:41 AM
and if I make the srt file like a html page and put the meta content type tag?
ok I will try that too
 
Could work. Simply saving the file as UTF-8 is easier, though.
 
Thank you very much
now it works
:)
 
Modern browsers interpret any resource as UTF-8 unless there is a Charset parameter that says something else
 
you can make an answer on my post to accept it please
now I understand what you told me
thank you
 
if you can't change the Charset parameter of the Content-Type header, just change your file encoding ;)
 
11:43 AM
I have changed the file encoding
and now it works :D
 
;-)
Hi T.J.
 
ok then I am waiting for a answer on my question page to accept it :D.. bye bye and thank's again
 
@Cata: OK