1

I am trying to display polish characters, for example:

Wype ł nij poni ż sze pola

But instead of it I have:

Wype Šnij poni ż sze pola

In my main page I have set UTF-8 and polish encoding:

     <%@ page contentType="text/html; UTF-8" pageEncoding="UTF-8"%>
     <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

     <html lang="pl-PL">
     <head>

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

On this page every character is displaying OK.

However, when using Magnific Popup jquery plugin in order to display different html (in my case jsp as it SpringMVC based application) chars are badly rendered (as mentioned above).

The whole content of the different html which I am trying to load:

<div class="white-popup-block"
    style="max-width: 600px; margin: 20px auto;">

    <form class="appnitro" enctype="multipart/form-data" method="post" action="/goSomewhere">
        <div class="form_description">
            <p>Wypełnij poniższe pola</p>
        </div>
    </form>
</div>

Should I add some endoding meta data to second page (above)?

Thanks for any help.

UPDATED

Here is code snippet which make an ajax call to 'different.html':

<script type="text/javascript">
  $(document).ready(function() {
    $('.simple-ajax-popup-align-top').magnificPopup({
      type: 'ajax',
      alignTop: false,
      tError: 'Nie można załadować <a href="%url%">elementu</a>.',
      overflowY: 'scroll' // as we know that popup content is tall we set scroll overflow by default to avoid jump
    });        
  });
</script>

<a class="simple-ajax-popup-align-top" href="/some/other/file">Open different Html</a>

Source code of the magnific popup: https://github.com/dimsemenov/Magnific-Popup

Jacek Gralak
  • 154
  • 2
  • 13

1 Answers1

2

Make sure that content of html that you're trying to load is actually saved with UTF-8 encoding.

To check this, open your file in browser and set browser encoding to UTF-8.

To convert file to different encoding, you can use built-in features of editors - ie. Notepad++ under Windows or PhpStorm (both Windows and Linux) provide such option.

Typically you'd set appropriate headers (like contentType: "application/x-www-form-urlencoded;charset=UTF-8") in your AJAX call, but Magnific Popup doesn't seem to let you configure this.

Michał Rybak
  • 8,386
  • 3
  • 40
  • 52
  • Thank you, the problem was with encoding indeed...nevertheless I was pretty sure that the file was encoded in UTF-8. In Notepad++ the file was encoded in: "UTF-8 without BOM" - do you know what is the difference between it and simple UTF-8? Btw: thanks again for solving my problem – Jacek Gralak Dec 10 '13 at 08:37
  • Take look at [this answer](http://stackoverflow.com/a/2223926/1995170) for the details, especially the comments, which may be relevant to what your problem was. – Michał Rybak Dec 10 '13 at 12:44