PHP函数用于解码具有不同编码的字符串

I have a couple of encoded strings with different encoding types for example: Zubeh%F6r and Zubeh%C3%B6r, which both need to be decoded to Zubehör. The first example string can be decoded with the PHP function urldecode() but the only solution I found for decoding the second string was with the javascript function unescape().

Question 1: How can I decode the second type of string with a PHP function?

Question 2: How can I make a PHP function where I can pass in a text with these two encoding types and the function automatically decodes the text correctly?

I could write a book about messed up encoding by now ...

Q1: it is double encoded, as you can see from the amount of "weird" characters.

Q2: that is quite a task. You could use some of the mbstring functions of PHP in order to check the type of encoding you have and then all change it to the one you want. Yet, when I recall it correctly, there are some issues in terms of detecting and changing all properly. There were some issues with this stuff in some projects in the past.

Some point of reference: https://secure.php.net/manual/de/book.mbstring.php