1

I want this string:

"Hartnäckigkeit zahlt sich aus"

Getting converted to this:

Hartnäckigkeit zahl sich aus

I tried this:

html_entity_decode( "Hartnäckigkeit zahlt sich aus", ENT_COMPAT, 'UTF-8')

But did not succeed.

7
  • try to use base64_enconde() Commented Feb 19, 2015 at 18:59
  • What output do you get now and what do you expect? Commented Feb 19, 2015 at 18:59
  • @bcesars base64_enconde() since when is this a php build in function? Commented Feb 19, 2015 at 19:00
  • @Rizier123 I expect this: Hartnäckigkeit zahlt sich aus Commented Feb 19, 2015 at 19:02
  • 2
    @user998163 are you sure this html entities are correct? Ã and ¤ Commented Feb 19, 2015 at 19:08

3 Answers 3

2

Your encoded string seems off from the beginning, and may have been created somewhere by wrongfully HTML-encoding an UTF-8 string as ISO-8859-1:

Example (source code in UTF-8 format):

echo htmlentities(
    "Hartnäckigkeit zahlt sich aus", ENT_COMPAT, 'ISO-8859-1'
), PHP_EOL;

Output:

Hartnäckigkeit zahlt sich aus

(same as Hartnäckigkeit zahlt sich aus)

Use this to decode it:

echo html_entity_decode(
    "Hartnäckigkeit zahlt sich aus",
    ENT_COMPAT,
    'ISO-8859-1'
);

Output:

Hartnäckigkeit zahlt sich aus
Sign up to request clarification or add additional context in comments.

Comments

0

I got your output doing this:

$test = "Hartnäckigkeit zahlt sich aus";
echo html_entity_decode($test, ENT_COMPAT, "UTF-8");

Your entity codes seem off.

Comments

-1

You can use utf8_encode ( $data );

See more about encode here

http://php.net/manual/en/function.utf8-encode.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.