Get iconv to convert my string

I have the following line:

ᴰᴶ Bagi

Can i include iconv in DJ Bagi ?

At first I tried:

 $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text); 

This led to the following notification:

 Notice: iconv() [function.iconv]: Detected an illegal character in input string 

On a PHP site, I saw someone using:

//IGNORE//TRANSLIT

Although this prevents the notification I receive:

Bagi

+4
source share
1 answer

Initially, I thought it was an encoding problem at your end, but if I copy + paste these characters locally from the soundcloud source page:

 ᴰᴶ Bagi 

and try to specify them, I get the same result as you. This means the data is UTF-8, but iconv does not recognize as a "child" D Unable to convert character, it complains (a bit wrong IMO) about illegal character.

Edit: It really is. The superscript D is not in Unicode Superscripts and Subscripts range , but it is phonetic in nature . This is probably why they cannot be matched with their "parent" letter. Here is more information about

As far as I can see, your only choice is to replace the characters manually.

The most primitive replacement example is

 str_replace("ᴰ", "D", $string); 

(note that your source file must be saved as UTF-8 for this)

For an elegant solution, you can build an array of source and replacement characters and pass this to str_replace .

Or call DJ Bagi and tell him to receive damned letters. You will notice that the Soundcloud URL builder has encountered the same problem.

 soundcloud.com/bagi 
+3
source

Source: https://habr.com/ru/post/1348178/


All Articles