Re: fwrite() seems to destroy Special Characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dennis Lahay wrote:
Ah, if were only that simple but, alas, it is not. I have opened other documents that contain these special characters and BBEdit has displayed them properly.

Are you using the same charset for both? What is the original source of the data? html form? then they are in the charset of the html page





On Nov 18, 2004, at 8:23 AM, Marek Kilimajer wrote:

You are not loosing them, only bbedit does not display them in the original charset. Look in the bbedit menu or configuration if you can find some character encoding setting




Dennis Lahay wrote:

I'm having trouble with writing special charcaters to a text file. The characters are your run-of-the-mill accented characters. Passing them back and forth in the database and displaying them on screen is NOT a problem.
code snippet:
$row = mysql_fetch_array($query_result, MYSQL_ASSOC);
foreach ($exportOrder as $key => $value) { // makes tab-delimited file from array
if (array_key_exists($key, $row)) {
$bigString .= $row[$key] . "\t";
} else {
$bigString .= "\t";
}
}
print $bigString;
$filename = "../../../Volumes/FILEJOB/DB Art IN/" . $row['currentSVVersion'];
if (!$file = fopen($filename, 'w+')) {
print "Cannot open file ($filename)";
exit;
}
fwrite($file, $bigString);
fclose($file);
I print the string immediately before I write the file. It looks like this (i hope this formats correctly for the list):
INGRÉDIENTS : VINAIGRE, EAU, GRAINES DE MOUTARDE, SEL, CURCUMA, ÉPICES À Â Æ Ç È É Ê Ë Î Ï Ô Û Ü Œ
I write the file, open it up in BBEdit (or your favorite text editor) and it looks like this:
INGR…DIENTS : VINAIGRE, EAU, GRAINES DE MOUTARDE, SEL, CURCUMA, …PICES ¿ ¬ ? « » … À †Œ œ ‘ € ‹ å
Why would I lose those special characters when writing to a text file? How can I avoid this? The text file will be opened offline, so using É and other character entities won't work.
I've tried:
- $file = fopen($filename, 'w+b'); adding binary flag doesn't affect anything
- Iooking at php.ini; nothing stood out
Any suggestions? [Mac OSX 10.3.6 : PHP 4.3.2 : MySQL 4.0.18 : Apache 1.3.29]



-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux