I need to store some data in a text file. The data is in my mysql as latin1 to use as few bytes as possible. How can I make a text file for php to write to in latin1 format please?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Whilst slightly off-topic, to be honest I’d be tempted to keep everything (web page, database connection, table/collation, output files, etc. in UTF-8), purely in the (quite possibly epically unlikely) eventuality that non latin1 characters are required at any point in the future.
Virtually all text editors, etc. support UTF-8 as-is and it’ll be easier to convert from UTF-8 to another format (and conversely from another format to UTF-8) if so required. Additionally, database (and disk space) is ridiculously cheap, so using up a few bytes here and there in comparison to committing to a limited character set would seem a bit of an excessive trade-off.
Incidentally, there’s a fairly canonical blog post related to such things by Joel Spolsky called: “The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)“. It’s well worth a read irrespective of which way you decide to go.