Jump to content

writing special characters to a text file using php's file system


V for Vincent

Recommended Posts

Hi there, I'm currently working on a page that gathers information for a year book. People answer a few questions (the answers are added to a plain text file), upload their own picture if they so choose, etc... Got most of it working at the moment, but as the page is in Dutch, diacritic signs should be properly handled. The page itself has UTF-8 encoding, as does the text file containing the answers and yet, if I try to add a tilde to my name, for instance, I get ñ in the text file. Is there any way to remedy this?

Link to comment
Share on other sites

Apparently that's not what's causing this. It's odd. I've created a stripped-down version of my page, even implemented other people's working code and it still doesn't work for me. Take this, for instance:

<?php$myString = "Test with accents éèàç";$fh=fopen('test.txt',"w");fwrite($fh,utf8_encode($myString));fclose($fh);?> 

Even that doesn't work. Could it be a server thing? Sure hope not, though... It's not my own server.(though apparently, it doesn't work on my local test server either)

Link to comment
Share on other sites

That does work for me, but different text editors show different things. ConTEXT, which doesn't have very good support for UTF, shows incorrect text. Notepad shows the correct characters. Web browsers show incorrect characters. I'll send you a private link to the phpinfo script on my server for you to compare settings, in particular check the settings for the mbstring module.

Link to comment
Share on other sites

Hey, thanks. Installing the extension did the trick. Strangely, I had to omit the utf8_encode operation for the above snippet to work after I had installed the extension, but finding out why that is isn't really that high on my priority list.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...