#29067Encoding UTF-8 in unescape function
Description
The best way to understand bug is look for video:
http://www.screencast-o-matic.com/watch/cXjbju3fU [^]
I solve problem in my typo3 version but I think that not only I have this problem.
SOLVE:
– file: t3lib/class.t3lib_tceforms.php:
line: 2799
change:
$onClickInsert .= 'new Insertion.Bottom($("' . $idTagPrefix . '"), unescape("' . rawurlencode($newElementTemplate) . '").' . $replace . '); setActionStatus("' . $idTagPrefix . '");';
to:
$onClickInsert .= 'new Insertion.Bottom($("' . $idTagPrefix . '"), utf8_decode(unescape("' . rawurlencode($newElementTemplate) . '")).' . $replace . '); setActionStatus("' . $idTagPrefix . '");';
and add somwhere JS function:
function utf8_decode (utftext) {
var string = ""; var i = 0; var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) { string += String.fromCharCode(c); i++; }
else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; }
else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; }
}
return string;
}
Sorry form my poor english :)
Reviews 5
- main 6208[BUGFIX] Incorrect display of Flexform UTF8 labels
- TYPO3_4-5 6209[BUGFIX] Incorrect display of Flexform UTF8 labels
- TYPO3_4-6 8831[BUGFIX] Encoding error in TCEforms inline JavaScript
- main 8792[BUGFIX] Encoding error in TCEforms inline JavaScript
- TYPO3_4-5 8790[BUGFIX] Encoding error in TCEforms inline JavaScript