Writing Certain Phrases To File Comes Out In Chinese?
Posted: Fri Jul 16, 2010 11:10 am
I'm using fopen(, "a") / flock() / fputs() / flock() / fclose() to write out a few small files. I'm writing out a line each time. The calling code passes in the string to write out, I add a \n, and that's it.
The four phrases I tried writing out were
Another element
Another format
Another liked genre
Another seeking genre
The first two never had a problem; the last two produced the Chinese characters!
The odd thing is, if I add the \n straight on to the end using
$Line . "\n"
or
"$Line\n"
it goes wrong; if I add at least one space first, then the \n, it works just fine.
I'm running PHP 4.4.7 on Apache 1.3.27 on my Windows 7 machine. (\n is just fine for a line ending here, I can read it in Notepad2 just fine).
Note that as per the PHP recommendation, I'm not using "t" on Windows but instead letting it use the exact line ending I specify.
Any idea what's causing this? The workaround will do for now, but I'd like to understand whay.
The four phrases I tried writing out were
Another element
Another format
Another liked genre
Another seeking genre
The first two never had a problem; the last two produced the Chinese characters!
The odd thing is, if I add the \n straight on to the end using
$Line . "\n"
or
"$Line\n"
it goes wrong; if I add at least one space first, then the \n, it works just fine.
I'm running PHP 4.4.7 on Apache 1.3.27 on my Windows 7 machine. (\n is just fine for a line ending here, I can read it in Notepad2 just fine).
Note that as per the PHP recommendation, I'm not using "t" on Windows but instead letting it use the exact line ending I specify.
Any idea what's causing this? The workaround will do for now, but I'd like to understand whay.