I'm trying to save a string in hebrew to file, while having the file ANSI encoded.
All attemps failed I'm afraid.
$to_file = "בדיקה אם נרשם";
$to_file = mb_convert_encoding($to_file, "WINDOWS-1255", "UTF-8");
$to_file = iconv("UTF-8", "windows-1252", $to_file);
The reason it doesn't work with
mb_convert_encoding is that mb_ doesn't support Windows-1255.
Detecting encodings is by definition impossible. Windows-1255 is a single-byte encoding; it's virtually impossible to distinguish any one single byte encoding from another. The result is just as valid in ASCII as it is in Windows-1255 or Windows-1252 or ISO-8859 or any other single byte encoding.