1

I have a database (ubbthreads) encoded in latin1 with content from latin2 (polish characters).

Since latin2 is compatible with latin1 it looks fine on the website, however I cannot convert it in any way to utf8 (want to import the data to nodebb).

It also doesn't render characters correctly in console mysql as well as in mysql workbench.

I tried numerous of ways to do the conversion and all of this failed.

My last try was to convert mysqldump file first from latin1 to latin2, and I planned to do next conversion from latin2 tu utf8.

However, iconv breaks in first polish character attempt with illegal input sequence at position 11392

I need some tips how to do it in a correct way.

  • Just for the record. I didn't have to use this in the end. Nodebb importer (also the reason to do this procedure) handles latin2 to ut8 converting on post-import phase with custom script just fine. However, I marked Alex'es answer as correct one, since this is one and probably only way to do it using mysql. – sznowicki Oct 11 '16 at 20:14
1

You can try something like:

INSERT INTO original_new()
SELECT CONVERT(CAST(CONVERT(`field` USING latin2) AS BINARY) USING utf8) 
FROM original
| improve this answer | |
  • Thank you, however that would be my last resort since it will require lots of work to create a script that will do the jobs. – sznowicki Oct 11 '16 at 16:56
1

In MySQL, you state two independent things:

  • The encoding of the bytes in the client, and
  • The encoding in the column in the table.

That is, you can have one of them be utf8 and the other be latin2. This is without any use of CONVERT(), etc.

Since it is unclear what settings you have where, I can't be more specific.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.