ko-n / Mp3StreamTitle

This repository contains two PHP libraries Mp3StreamTitle and Radio101RuTitle.
Apache License 2.0
6 stars 0 forks source link

Help with PHP script displaying Spanish characters correctly #2

Open shelomito12 opened 3 years ago

shelomito12 commented 3 years ago

Both the file where the php redirects its output and the console/terminal output on my Ubuntu server display: "Antonio Piñero - Mateo,..." The above should display as: "Antonio Piñero - Mateo,..."

Screenshot from youtube live stream: image

Is it possible to modify the php scripts to support Spanish characters?

Thanks in advance!

ko-n commented 3 years ago

Hi! I think the problem is with the files encoding. Please, check the encoding of the PHP files that are responsible for displaying information about the playing track. Files must be encoded "UTF-8".

Also, your problem can be solved with the following code: $mp3_stream_title = mb_convert_encoding($mp3_stream_title, 'UTF-8', 'ISO-8859-1'); But I recommend that you check the files encoding. Because when I tested the script on my local server, I had no problems displaying Spanish characters.

If all PHP files are "UTF-8" encoded and Spanish characters are not displayed as expected, write here.

shelomito12 commented 3 years ago

I used Notepad++ to quickly check the encoding of the file: image

As you can see it shows the encoding as UTF-8.

Pardon my ignorance: Where/Which line number of the PHP script should I add $mp3_stream_title = mb_convert_encoding($mp3_stream_title, 'UTF-8', 'ISO-8859-1'); ?? Should I add this on the main PHP script or the one I run which has the radio URL stream?

Thanks in advance.

ko-n commented 3 years ago

Here, using an example from the file "README.md", you can see how you can use the solution to the problem that I suggested above:

<?php

require_once('Mp3StreamTitle/Mp3StreamTitle.php');

use Mp3StreamTitle\Mp3StreamTitle;

$mp3_stream_title = new Mp3StreamTitle();

// Instead of "http://example.com" specify a direct link to the stream of any online radio station.
$stream_title = mb_convert_encoding($mp3_stream_title->sendRequest('http://example.com'), 'UTF-8', 'ISO-8859-1');

echo $stream_title;

I do not like the solution to the problem that I proposed above, so could you please send me a copy of your files, which you use to display information about the playing track, to my email address?

shelomito12 commented 3 years ago

Hey Oleg, I sent you an email with my php files as requested.

PS: I had to remove UTF-8 and just leave ISO-8859-1 and it's working now, but I'll keep monitoring. Thanks!

shelomito12 commented 3 years ago

Using only 'ISO-8859-1' was working fine with some Spanish characters but was still getting some characters not encoding properly so now I'm testing both 'UTF-8' and 'ISO-8859-1'

ko-n commented 3 years ago

Sorry for the delay in reply! I checked your PHP files, they are OK. The files have the correct encoding. Unfortunately, I do not know why there are problems with the display of some Spanish characters.

Did you find the perfect solution?