While looking for RFC 2231 / 2184 implementations i found yours.
https://sourceforge.net/p/squirrelmail/code/HEAD/tree/trunk/squirrelmail/class/mime/Rfc822Header.class.php#l746
It seems to have a small bug as that line should be $value = substr($value,strlen($language)+1);
As the charset and language fields can have (and most likely do) have different length.
I also submitted the change to some github fork (https://github.com/RealityRipple/squirrelmail/pull/13)
Instead of relying on the substr & strlen you can also use $value = explode("'", $aResults[$key], 3); (not 1:1 replacement) for a bit better overview what is happening there.