0

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?

2
  • Using UTF-8 won't take up any more space unless it actually needs to. Is the usage of latin1 set in stone? (Bit retrograde, hence the question.) Commented Jan 20, 2011 at 22:29
  • Not set in stone as such, just storing a LOT of text (a-z and 0-9) no fancy stuff, so thought their might be a way Commented Jan 20, 2011 at 22:33

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.