[Typo3-dev] tslib_fe->csConv()
Kasper Skårhøj
kasper at typo3.com
Tue Apr 20 20:22:09 CEST 2004
> Is it correct that this method should only be used to convert labels?
> That is when used without the optional $from argument.
It is designed to convert labels from locallang files. For instance in
mininews there are labels for polish in the locallang files which are
stored in the polish charset (can't remember). If the site charset
(config.metaCharset) is set to eg. utf-8 then these iso-something labels
in polish should be converted. That is what this function handles.
Using the $from parameter you can do any conversion to the metaCharset
charset.
>
> I was thinking about two other possible conversions: from DB charset and
> from locale charset.
>
> So instead of the mentioned method perhaps we could have these ones:
We cannot have things *instead*. We can have things in *addition*. Guess
why.
>
> tslib_fe->labelConv()
> tslib_fe->dbConv()
> tslib_fe->localeConv()
>
> labelConv() is just a new name for consitency.
Lets stick to the old name - we don't know how many hundreds of
extensions are using the function already... :-)
>
> dbConv would get it's "internal" conversoin arguments by
> SYS[forced_charset] and config.metaCharset. Can be used on results of
> SQL queries.
Where would this function be called? If people know the charset of the
input string they just use "csConv" with the second argument set.
BTW, there is a property for stdWrap called "csConv" which allows just
that.
Considering logic regarding forceCharset might make some sense but it's
not vital
Say that all information in the system is in iso-8859-1 and you want
utf-8 pages for some reason. Then something like "page.stdWrap.csConf =
iso-8859-1" will do the trick if "config.metaCharset = utf-8"
>
> localeConv could make some eductated guess on the charset of the locale,
> but should make use of an override via something like
> config.localeCharset. Can be used on results of locale dependent system
> libraries (like strftime()).
I'm not into that.
Could we start by making the intelligent function for finding the
charset of the locale and then just use csConv?
I suggest we implement this for the places where TypoScript offers to
extract locale dependant information (like stdWrap.strftime)
>
> The initialization of the interbal charset vars could be moved into the
> "constructor" (instead of initLLvars).
Lets keep it in csConv. There it is initialized if used and creates no
significant overhead.
> Guessing of the locale charset could be done via a platform dependent
> (Unix uses mostl iso, Windows MS uses specifc charsets, OS X uses ???)
> mapping table.
>
> Something like this:
>
> Take the language part out of the locale (de_DE => de, pl-PL => pl,
> italian => it).
> Make a lookup in the table of the platform (de: Unix => iso-8859-1, MS
> => windows-1252)
Whatever.
As long as there is some hardcoded way to set it when the intelligence
breaks.
- kasper
More information about the TYPO3-dev
mailing list