[TYPO3-core] RFC: Respect target if specified in file header

Michael Stucki michael at typo3.org
Thu Dec 1 18:12:02 CET 2005


Hi folks,
this is another CVS patch request.

Problem:
It happened a few times that we converted a site into UTF-8 but all files
were still stored as ISO-8859-1. So when TYPO3 imported the files (e.g.
template.html) the special chars were broken because TYPO3 expected them to
be UTF-8.

Solution:
This patch extends t3lib_div::getUrl() and t3lib_div::writeFile() with a new
function that reads the first three lines from the content and looks for a
predefined character set definition. If such a character set is found, the
content is converted from/into the internal character set of TYPO3.

Examples:

XML/HTML files:
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="#internalStyle" type="text/css"?>

CSS files:
@charset "ISO-8859-1";
body {
    /* This is a comment that contains äöü special characters */
    font-size: 20px;
}


Comments:

- The five-line detection works but is ugly. If anybody has a better way for
this, please let me know.

- The character set lookup is based on a regular expression that can be
extended easily.

- I am undecided whether PHP files should be converted, too (e.g. when
editing them in the Extension Manager). Any suggestions?

- I did not find any examples but fear that there are calls of these
functions where the CS conversion should be skipped. In this case, please
change these functions and submit the $noCSconv parameter (see
t3lib_div::getUrl() and t3lib_div::writeFile()).

Comments welcome.

- michael
-- 
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: csconvert.diff
Type: text/x-diff
Size: 4079 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20051201/e1bbb852/attachment.bin 


More information about the TYPO3-team-core mailing list