ApPeL
ApPeL

Reputation: 4921

jQuery not showing Swedish characters correctly

I wrote a small snippet in jQuery to just put a search word into my searchbox in wordpress, then when clicked to disappear.

<script type="text/javascript">
            var $j = jQuery.noConflict();

            $j(function(){
                $j('#s').click(function() {
                    $j(this).val('');
                });

                var search = "Sök på sajten...";

                $j('#s').val(search);
            });
        </script>

currently when I get to the site it looks like this. S�k p� sajten...

What has to be changed?

Upvotes: 0

Views: 687

Answers (2)

Gustav Barkefors
Gustav Barkefors

Reputation: 5086

A quick/dirty way to cope with these issues when you're dealing with hardcoded strings is to unicode escape your JS (ö = \u00f6 in your case).

However, Brandon's suggestion above is the recommended approach - note that the meta tag isn't enough, you must make sure that the file (or rather, the content ultimately served to the client) actually IS utf-8 encoded.

Upvotes: 1

Brandon Frohbieter
Brandon Frohbieter

Reputation: 18139

ensure you are using the utf-8 charset

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

if this is the case, you can try encoding the characters( å = & #229; (minus the space)), and see if that gets you anywhere.

Upvotes: 1

Related Questions