Link to home
Start Free TrialLog in
Avatar of pdd
pdd

asked on

ModalBox encoding problem

I want to use ModalBox (http://code.google.com/p/modalbox/) but I'm having problem displaying the content.

The content of the modalbox is retrieved from a page that is not UTF-8 concoded, so on the page "?" apear.

How can i fix it ?
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pdd
pdd

ASKER

I don't want to use it as UTF8, I want it to be ISO-8859-1
So you convert YOUR page to iso-8859-1 and the problem is solved...
Or am I missing something...

If your page is iso-8859-1 then you need to change all occurrences of UTF8 in the modal code like here

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

Open in new window

Avatar of pdd

ASKER

The page is with that meta tag.

Let me explain again:
On a page that is  iso-8859-1 i retrive some content using ajax (prototype fw) and then display it on the page.
The content retrieved  is  iso-8859-1 encoded, the page is also like that, but when i put the content on the page it appears with "?".
I even tried to make the encoding of the request to be   iso-8859-1 but that didn't solved the problem
I understand. The modalbox code is UTF8

Searching for: utf
modalbox1.6.0\lib\prototype.js(1182): encoding:     'UTF-8',
modalbox1.6.0\tests\functional\_ajax_form.html(1): <form action="#" method="get" name="form" id="form" accept-charset="utf-8" onsubmit="Modalbox.show('_ajax_form.html', {title: 'Step 2', width: 500}); return false;">
modalbox1.6.0\tests\functional\_ajax_js.html(3): <script type="text/javascript" charset="utf-8">
modalbox1.6.0\tests\functional\func-modalbox-test.html(6): <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
modalbox1.6.0\tests\functional\func-modalbox-test.html(31): <form action="#" method="get" accept-charset="utf-8">
modalbox1.6.0\tests\functional\func-modalbox-test.html(39): <script type="text/javascript" charset="utf-8">
modalbox1.6.0\tests\unit\_ajax_content_js.html(2): <script type="text/javascript" charset="utf-8">
modalbox1.6.0\tests\unit\unit-modalbox-test.html(6): <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
modalbox1.6.0\tests\unit\unit-modalbox-test.html(42): <script type="text/javascript" language="javascript" charset="utf-8">
Found 9 occurrence(s) in 6 file(s)

Open in new window

Avatar of pdd

ASKER

Yes, I changed
modalbox1.6.0\lib\prototype.js(1182): encoding:     'UTF-8',
to iso-8859-1 but that didn't helped.

Do you have any idea how to solve this ?
No - not if the above did not do it.... But UTF8 is the way to go anyway so I still suggest you convert your data to UTF8
Keep in mind that to have the page sent as UTF-8 doesn't necessarily mean you need to convert the page itself.  You might be able to have the server do it for you.  Are you using a server language or getting the content from a DB?  If so provide details.  I believe I have seen third-party components you can add to the server and some languages/technologies may be able to do this for you without an addon object.

I don't know if this will help but provide details and let me know if you want more info on this.

bol
Avatar of pdd

ASKER

Hi b0lsc0tt.

The ModalBox get's the content of a page that is generated using PHP.
Yes, I could convert the page to UTF-8, I allready done this on several pages, but I don't want to / can't do it for some other pages.
Since it is coming from server script anyways all you would have to do, in PHP, is add the line below to the top of the PHP script.

header("Content-type: text/html; charset=utf-8");

Is that what you have tried on other pages but don't want to do here?  Hopefully it is actually something else and more complicated because this is so simple and easy (but should do it) that I can't imagine it wouldn't be something you would do in these pages.

Let me know if you have a question.  Thanks for the details and response you provided.

bol
Avatar of pdd

ASKER

Yes, setting the header is what i've done on some pages, but i actually made the header

header("Content-type: text/html; charset=iso-8859-1");

The problem with other pages is that they are external, so i can not modify the pages or the headers using JS.
In this case the solution would be a proxy, but I can not use a proxy because all functions that get content from outside do not work (disabled by admins).

So another solution would be to use an external proxy, but that only of there is no way to do it with only JS
Mplungjan could confirm this but I don't know any way for JS to convert the charset used.  An external proxy, what he originally suggested, sounds like what you need to use in this case.

Let us know if you need any more help or have a question.

bol
I do not know of a way in JS to convert the charset. It may exist but I cannot think of how
Avatar of pdd

ASKER

The only question would be how to make it in JS ?
Isn't that what we just responded to?  You can't do it in Javascript.  If you are asking something new then please clarify.  Otherwise Javascript doesn't provide a way to change or convert the encoding like you need.

bol