简体   繁体   中英

Force String in JavaScript to be UTF-8?

my JS-File is UTF-8 encoded, my html document also.

I also have this in the head part of the HTML:

<!doctype html>
<html lang="de">
<head>
    <meta charset="utf-8" />

Every umlaut that I typed in the HTML is displayed properly.

But if I try to set a new value with $('#test').text('Test öäü') I get Test öäü .

How is this possible? Even console. debug/log and alert() display the same.

I also tried to set the charset attribute on my script-tag, but nothing worked.

Can anybody help me with this issue?

I found the issue. I use minify to combine my css/js and minify had $min_serveOptions['contentTypeCharset'] set to iso-8859-1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM