tool
tool

Reputation: 204

Multiple character encodings inside one HTML page possible?

I have a webpage that is set to UTF-8. But parts of its content (built in php) come from iso-8859-1 files and are thus not displayed correctly.

Is it possible to set a specific encoding for a particular page element?

Upvotes: 2

Views: 3848

Answers (5)

aeon
aeon

Reputation: 89

You could, instead of including that output directly, pass that php output through a conversion script.

PhP has a decent conversion function mb_convert_encoding that could make the task easier.

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1503439

How are you inserting the Latin-1 files into the page? If you're loading them as text and then including them as text, then I'd hope the relevant conversion would be performed for you. If you're just including the files without any transformation, that would indeed be an issue.

I don't know what PHP uses as its internal text format (e.g. Unicode) but if you can use that as an intermediate encoding, it should be okay.

Upvotes: 0

slim
slim

Reputation: 2583

You may end up using an iframe to display the other content so you can set your meta tag for the character encoding you need.

Upvotes: 0

TuomasR
TuomasR

Reputation: 2316

No, only a single encoding can be used on one page. You might want to encode your iso-stuff to entities that's generated by PHP.

Upvotes: 0

Vasilis Lourdas
Vasilis Lourdas

Reputation: 1179

No, I don't think this can be done. Since you already use UTF-8 inside the page, there must be something wrong while reading the content from other pages if you get unexpected results. You shouldn't experience any problems with a UTF-8 page.

Upvotes: 0

Related Questions