Fork me on GitHub
Subscribe 3

Ticket #904 (fixed bug)

Charset conversion in db_update.php doesn't work

  • Created: 2013-09-23 17:10:23
  • Reported by: Koos
  • Assigned to: Franz
  • Milestone: 1.5.5
  • Component: upgrading
  • Priority: normal

Has no one ever tried to convert a PunBB 1.2 / FluxBB 1.2 board with a non "ISO-8859-1" charset (e.g. windows-1251) to UTF8 when upgrading to FluxBB using db_update.php? Well, it doesn't work. I've attached a patch that will fix this. Also: only the core tables are converted. What about the tables installed via mods, e.g. private messages?

History

Koos 2013-09-23 17:12:27

  • Description changed. (Diff)
  • Uploaded patch patch_iconv.patch. (view)

Studio384 2013-09-23 19:17:19

  • Component set to upgrading.
  • Milestone set to 1.5.5.

Franz 2013-10-02 16:05:09

I don't think we can take care of converting modification tables. We've never handled them in any way during upgrades.

Visman 2013-10-03 01:03:35

For myself I did so

	if ($old_charset != 'UTF-8' && !seems_utf8($str))
	{
		// Visman
		if (function_exists('iconv') && strpos($old_charset, '1251') !== false)
			$str = iconv('CP1251', 'UTF-8//IGNORE//TRANSLIT', $str);
		else if (function_exists('mb_convert_encoding') && strpos($old_charset, '1251') !== false)
			$str = mb_convert_encoding($str, 'UTF-8', 'CP1251');
		// Visman
		else if (function_exists('iconv'))
			$str = iconv($old_charset == 'ISO-8859-1' ? 'WINDOWS-1252' : 'ISO-8859-1', 'UTF-8', $str);
		else if (function_exists('mb_convert_encoding'))
			$str = mb_convert_encoding($str, 'UTF-8', $old_charset == 'ISO-8859-1' ? 'WINDOWS-1252' : 'ISO-8859-1');
		else if ($old_charset == 'ISO-8859-1')
			$str = utf8_encode($str);
	}

The standard code didn't convert the russian coding.

Franz 2013-11-14 00:27:23

  • Owner set to Franz.

Franz 2013-11-14 00:31:36

Commit 6d3729b to fluxbb master

#904: Actually use old charset when converting to UTF-8. Thanks, Koos.

Franz 2013-11-14 00:33:41

  • Status changed from open to fixed.

Fixed now, I think. Weird, I guess we were only expecting default charsets for old PunBB/FluxBB installations. Sorry about that!

Koos 2014-03-20 20:58:15

A suggestion for converting non-core tables to UTF8 when upgrading from PunBB 1.2 / FluxBB 1.2:
https://github.com/Koos10/fluxbb/commit … ce8b153188