1

I have this in my header

<meta charset="utf-8">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />

and this in my htaccess:

# UTF-8 encoding
# ----------------------------------------------------------------------

# Use UTF-8 encoding for anything served text/plain or text/html
AddDefaultCharset utf-8

# Force UTF-8 for a number of file formats
AddCharset utf-8 .css .js .xml .json .rss .atom

My browser is google chrome. When i use a javascript variable as output in the html a 'ä' becomes 'ä' ?

3
  • Please show more details about what goes wrong when Commented May 31, 2012 at 13:18
  • Please check encoding file with umlauts. Commented May 31, 2012 at 13:19
  • Check in your google chrome settings from top right, select tools-> encoding and see if it's set to utf-8 when viewing the page. Commented May 31, 2012 at 13:22

2 Answers 2

1

You should either set the correct charset in <script> tag that includes your file or encode all symbols outside of plain ASCII range as unicode entities - \xNNNN and thus make file charset-neutral. Some minifiers, like Google Closure Compiler, can do this for you.

Sign up to request clarification or add additional context in comments.

6 Comments

like this <script type="text/javascript"> ?
<script src="file.js" type="text/javascript" charset="utf-8"></script>
has unfortunately no effect for me
Of course you should write correct encoding of your file, not just copy/paste "utf-8" from this example. Some comments on other answers suggest that you actually have ISO-8859-1 instead.
i switched everything to ISO-8859-1, now a ä is this ä
|
1

Do you also save the document as UTF-8? If you are using Notepad++, try to change the coding of the document, save and refresh site.

2 Comments

i use aptana studio and in the preferences general/workspace/text file encoding UTF-8 is selected, i think that should be it shouldn't it ?
@user1011185 "ä" are the bytes (0xC3A4) of utf8 encoded "ä" in encodings like ISO-8859-1, please check your encoding in tools->encoding in chrome

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.