cakephp / cakephp/phinx

Encoding problems in legacy code - latin1

Open
#987 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

docs support
Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

Hi,

I have inherited a legacy application that has code in a lot of different encodings and a lot of tables in different encodings. This means that i cannot just use the charset defined in the phinx.yml.

I am trying to create a migration for a specific table that is in latin1. So for example im trying to insert the following text 'La Réunion' into a field in the latin1 table but once in the database it is 'La R?union'

How can i set the encoding just for the current table being manipulated in the migration.

I have tried:

$table = $this->table('tablename'); //latin1
$table->setOptions(array('encoding' => 'iso-8859-1'));
or
$table->setOptions(array('encoding' => 'latin1'));

is what I am trying to do possible with phinx and if so what should I be doing?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the migration's table() call and the setOptions() handling for encoding, then inspect how the database adapter processes writes to a table with a latin1 charset. Reproduce the migration with 'La Réunion'; done means the text is stored without becoming 'La R?union' and the supported configuration is documented or tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.