Character set conversion G1->G2

twinprime

Joined: 2007-03-20
Posts: 3
Posted: Tue, 2007-03-20 14:15

During migration from G1->G2, is there a way to have Gallery NOT convert characters on the website to UTF-8?
I've tried with different "Source Character Set" and it always converts w to Unicode UTF-8. I have yet to find an option to turn this off.

I'm using Windows ISO to display characters of another language.
Special characters on my gallery are in the form

Quote:
Ӓ(ampersand, pound and number and semi-colon).

However during migration the program changes the ampersand to

Quote:
&amp

making it looks like an actual ampersand, thus totally break the display of special characters.

Is this an option? If not where (in the gallery2 php code) should look and change to turn this off? It's really frustrating.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2007-03-20 14:56

it's not an option.
g2 stores everything in utf-8 only.

you might want to add $utf8String = GalleryUtilities::unicodeEntitiesToUtf8($yourString);

so the final code should be:
$originalString = something from g1;
$utf8String = GalleryCoreApi::convertToUtf8($originalString, $sourceEncoding);
$utf8String = GalleryUtilities::unicodeEntitiesToUtf8($utf8String);
$utf8String = GalleryUtilities::sanitizeInputValues($utf8String, false);

so much about the theory.

to fix your import module, edit modules/migrate/ConfirmImport.inc

around line 1424
replace

    function convertHtml($markupType, $item, $sourceEncoding='UTF-8') {
	$item = GalleryCoreApi::convertToUtf8($item, $sourceEncoding);
	switch ($markupType) {
	case 'bbcode':
	    $item = ConfirmImportController::convertHtmlToBbcode($item);
	    break;

	case 'html':
	    break;

	case 'none':
	default:
	    $item = strip_tags($item);
	}
	GalleryUtilities::sanitizeInputValues($item, false);
	return $item;
    }

with

    function convertHtml($markupType, $item, $sourceEncoding='UTF-8') {
	$item = GalleryCoreApi::convertToUtf8($item, $sourceEncoding);
	switch ($markupType) {
	case 'bbcode':
	    $item = ConfirmImportController::convertHtmlToBbcode($item);
	    break;

	case 'html':
	    break;

	case 'none':
	default:
	    $item = strip_tags($item);
	}
$item = GalleryUtilities::unicodeEntitiesToUtf8($item);
	GalleryUtilities::sanitizeInputValues($item, false);
	return $item;
    }

--------------
Doumentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage

 
twinprime

Joined: 2007-03-20
Posts: 3
Posted: Sat, 2007-03-24 05:05

Thank you so very much.

(You put the 2 code blocks reverse, but it's pretty obvious if you've been digging through the import script for this)