-1

I have this string: Deportivo La Coruña, if I return it I'll get: Deportivo la coruña, so I tried to handle the encoding in this way:

$homeName = "Deportivo La Coruña";
return mb_convert_encoding($homeName, 'UTF-8', 'UTF-8'),

but same problem. I tried also utf8_encode but same result. How can I fix this issue without installing external libs?

utop
  • 111
  • 9
  • Could you clarify "return"? – Roland Starke May 20 '18 at 11:36
  • All it takes, is one wrong charset setting in your application - *everything* needs to be the same charset! I have previously written [**an answer about UTF-8 encoding**](https://stackoverflow.com/a/31899827/4535200) that contains a little checklist, that will cover *most* of the charset issues in a PHP/MySQL application. There's also a more in-depth topic, [**UTF-8 All the Way Through**](https://stackoverflow.com/q/279170/4535200). Most likely, you'll find a solution in either one or both of these topics. – Qirel May 20 '18 at 11:43
  • @Qirel I'm using Slim, I'm developing an API – utop May 20 '18 at 12:55
  • @RolandStarke `return` is used inside a function for return a value that could be an integer, a boolean, or as in this case a string. – utop May 20 '18 at 12:56
  • @utop Sounds like you got a broken charset somewhere in your application. Go through the two posts I linked. :) – Qirel May 20 '18 at 14:55

1 Answers1

-1

I think the $homeName = "Deportivo La Coruña"; is in ISO-8859-1

return mb_convert_encoding($homeName,  'ISO-8859-1' ,'UTF-8');

Use this to achieve your result.

Pang
  • 9,564
  • 146
  • 81
  • 122
Boopathi D
  • 361
  • 2
  • 21