I'm using PHP to generate RSS feeds and have set character encoding in the XML as UTF-8.
I know that if I want to save a Unicode text file using Notepad, normally I need to actually select UTF-8 (from a dropdown including ASCII, Endian, etc.).
Is there a way to specify this when creating a text file in PHP? If so, please let me know how. Conversely, please let me know if this is not even necessary.
well, not totally sure which part yr referring to. most text editors have a utf-8 toggle in them somewhere and that will affect the encoding of the PHP file itself.
if you're trying to make sure your CONTENT is sending as utf-8 then you can specify that using a header() command. (note: header() commands must be sent before any rendered html or other code is sent to the browser.)
I think we are on the same page (horrible pun in afterthought), except I'm not talking about serving a page, I'm talking about generating an XML file (RSS feed) and saving that to the server. When saving a text file with PHP, can I save it as UTF-8? Even though the XML content may state that the character encoding is UTF-8, the file itself may not be.
inetersting question. The first thing you’ll need is an editor that supports UTF-8. Say for example BablePad rather then depending on NotePad.
Secondly, you can put real utf8 characters directly in PHP file without the use of any Character/Numeric/Hexadecimal Entity References or any other special escape sequences. Using the real characters in place of character references makes one file easier to view and reduce its size. In this case, you requires PHP file to be save in unicode(UTF-8) format. Even you can name this same PHP file in UTF format like folder/your-*%4#@language.php. XML user agents requires full utf-8/16 support and it also includes BOM.
Finally, if you are using Character/Numeric/Hexadecimal Entity References in you PHP file, then you can go ahead saving it in normal way.
This is what i learned so far :) I am looking for few more commennts.