Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
Thread: UTF8 for php files.
09-09-2013, 05:23 PM #1
UTF8 for php files.
Should i convert my php files in my script from ANSI to UTF8 no mark?
I have really been struggling over this now for a few days. I have gone back and forth and back again. Advantages, disadvantages and back again.
It is what i consider a small to mid size script of 741 files with smarty occupying about 1/3 of those.
I keep telling myself if it works dont fix it.. But then again if i dont then i could be limiting my market.
Right now my tables are all latin1 swedish ci
I do set some of the files in the header to utf8 but my php files themselves are saved as ANSI.
One of my biggest objections is that if i dont do this correctly i could fall prey to the following which comes from the utf8 wiki.
A UTF-8 parser that is not compliant with current versions of the standard might accept a number of different pseudo-UTF-8 representations and convert them to the same Unicode output. This provides a way for information to leak past validation routines designed to process data in its eight-bit representation
I wish there was one question i could ask myself to know wether this was worth doing or not. The only thing i could come up with so far is:
"Is the script going to be available to foreign markets which would require this flexability" And my answer to that would be not as a major influence. But still it bothers me.
Any ideas from anyone of how you finally decided what to do if you have faced this challenge or what you would recommend.
09-09-2013, 06:48 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
Are you needing to store UTF data within a PHP script? If not, don't waste your time fudging it. The UTF8 can be handled from an external datasource and typically speaking I see little to no reason to store UTF8 within a PHP script since the language is englishish.
The problem is that the BOM damage the PHP script headers. Technically it can be handled from ini/htaccess level output buffering, but IMO that's a problem with the script itself and should be resolved.
Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');
Users who have thanked Fou-Lu for this post:
09-09-2013, 07:04 PM #3
no there is no need for me to store UTF. I was also concerned about the BOM, as it has affected my html files and i have resaved those over to UTF8 no mark so that they pass validation. But i have had no such issue with the php files as of yet (knock on wood).
I am leaning toward just keeping this version the way it is as far as the php files being ANSI and focusing my attenton on other more important tasks such as my conversion to the MySQLi library and recoding my security license code to accept resellers.
This is my third script i have converted to MySQLi and so its going quite well so far. More time consuming is prob going to be with this one is that i know i have quite a few class files that have the deprecated &new for new objects which i will need to fix, but that is more tedious than anything else.
Thanks for the input