0

I have this kind of text:

/> 23 visível (diagonal)<br /> Energy Star<br />

I want to convert it to a real texto to show on browser....

I've tried htmlentities method, but i'm getting this:

 23 visível (diagonal)
 Energy Star

And i should get:

visível (diagonal)
Energy Star
Guerra
  • 2,792
  • 1
  • 22
  • 32
  • Which encoding does your original string have? – ComFreek Oct 23 '13 at 14:02
  • 2
    [What Every Programmer Absolutely, Positively Needs To Know About Encodings And Character Sets To Work With Text](http://kunststube.net/encoding/) – deceze Oct 23 '13 at 14:07
  • Everyone suggests `utf-8` or `htmlentities`. But your original string has no reserved characters, as everything has already been converted to a `htmlentity`, leaving only just characters. It seems to me you want to strip `htmlentitied` characters...have i lost the plot, what am i missing? – gwillie Oct 23 '13 at 14:25

2 Answers2

0

Your result looks like utf8 for me... You could try with an additional

utf8_decode( ... ). 

But the real answer is to change the default encoding header to utf8 in apache or with

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

php by default should use utf-8 (see php.net)

Erik255
  • 1,463
  • 1
  • 11
  • 13
  • +1 for @deceze for the link it's a good advise to do some reading... – Erik255 Oct 23 '13 at 14:11
  • Work for me but i need to use both urf8_decode and header.... what about save on database? How i can do to save with the right characters?? – Guerra Oct 23 '13 at 16:13
0

To display corectly utf-8 characters, add this code at the beginning of your php script:

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

And this code in html5 document:

<meta charset="utf-8" />
CoursesWeb
  • 4,179
  • 3
  • 21
  • 27
  • Work for me but i need to use both urf8_decode and header.... what about save on database? How i can do to save with the right characters?? – Guerra Oct 23 '13 at 16:13