I would like to introduce you to one problem to see if there is any standard solution to solve it and to be able to apply it in different places across Moodle.
I've one UTF-8 file I've loaded into a PHP variable. Call it $originaltext.
Now I want to send it both to DB and to the browser without losing anything. I can imagine this situations:
- DB is set to UTF-8 and browser is set to UTF-8
- DB is set to ISO-8859-1 and browser is set to ISO-8859-1
- DB and browser have different charsets (but only UTF-8 and ISO-8859-1 combinations)
- DB or browser has non UTF-8 nor ISO-8859-1 charsets.
Now the questions:
- Are all of the above possible? Can I ignore any of them?
- Is there other possible combinations?
- How can I know both the DB and browser charsets being used? I know that, in some places the user->charset is used but, is this enough stable? Shouldn't it go to some more central and unalterable place? Once specified it should be easier to implement "translations" everywhere, I think.
- It seems to be different alternatives to do the work (mbstring, iconv, utf_decode...) but I would like to know if somebody have worked with this issue under other applications (OpenSource and PHP preferred, of course). Any suggestions?
This is only the first approximation to the problem, trying to know what charsets are intended to co-exist in Moodle and how to manage them. Any idea or comment will be welcome. Sure that, once the bases (objectives) were stabilised (approved) we could continue talking with more details about things like the UTF-8 transition, lang files and so on, so please, don't hurry up too much in this discussion.