PHP encode string for extended ASCII 8 bit 255 Sign


To represent also umlauts in a bit, can you get the extended ASCII character set use with 255 Sign, It contains also umlauts like ä, ö, ü and ß.

In order to use this, can I use the following function:

/**
 * @param string $string
 * @return string
 */
protected function asciiEncodeString(string $string): string
{
    $sourceEncoding = mb_detect_encoding($string);
    $destinationEncoding = 'CP437'; // Extended ASCII - Codepage 437
    $string = iconv($sourceEncoding, $destinationEncoding, $string);
    return $string;
}