Ello
Ello

Reputation: 917

Send polish characters in ISO-8859-1 environment with a html form

I have the following problem:

I have a webpage with a ISO-8859-1 charset.

Inside this page i have a form with the argument

accept-charset="UTF-8"

The form will be send with the post method

Now i want to submit polish letters mixed with latin letters

test ł,ą,ę,ś,ć,ż,ź,ó test

And want to display the result with PHP.

I tried several combinations of mb_convert_encoding, utf8_encode / utf8_decode, iconv and everything else. But the display is not right.

I just want to say to the browser: the page charset is iso-8859-1 but this small area is UTF-8

Upvotes: 4

Views: 6309

Answers (1)

deceze
deceze

Reputation: 522005

You cannot do anything with character encoding conversion here. Polish characters simply cannot be encoded in ISO-8859-1, full stop. If you do not want to change the encoding of your website to an encoding which can encode Polish and other characters (such as ISO-8859-2, UTF-8 or similar), all you can do is to represent these characters as HTML entities:

echo htmlentities($utf8Text, ENT_NOQUOTES, 'UTF-8');

You cannot make part of the page be encoded in a different encoding.

Upvotes: 3

Related Questions