Home  >  Article  >  Backend Development  >  Convert UTFo Windows 0

Convert UTFo Windows 0

王林
王林Original
2024-08-05 15:46:56830browse

Convert UTFo Windows 0

When working with different encodings, it may be necessary to convert text from one format to another. If you need to convert text from UTF-8 encoding to Windows-1250 using PHP, the script below can help you. This script performs the conversion and offers the output text for download.

$fileName = 'encoded.txt';
$inputText = 'Example text';

setlocale(LC_CTYPE, 'cs_CZ');
$output = iconv('UTF-8', 'Windows-1250//TRANSLIT', $inputText);

ob_clean();
header("Expires: Mon, 1 Apr 1970 05:00:00 GMT");
header(sprintf("Last-Modified: %s GMT", gmdate("D,d M YH:i:s")));
header("Pragma: no-cache");
header(sprintf("Content-type: application/octet-stream; charset=windows-1250; name=%s", $fileName));
header(sprintf("Content-Disposition: attachment; filename=%s", $fileName));
header(sprintf("Content-Length: %s", strlen($output)));
header("Content-Transfer-Encoding: binary");
header("Content-Description: Export dat");
echo $output;
exit;

This tool makes it easier to work with texts in different encodings, especially if you're dealing with Czech characters or other Central European languages. I hope you find it useful!

The above is the detailed content of Convert UTFo Windows 0. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn