0

For some reason, every file that I bake with CakePHP's console is regarded as ISO-8859-1 encoded by my IDE Dreamweaver. This works fine up to the point where I end up typing a special character, which will be wrongly displayed by the browser, since its encoding (by the editor) differs from the overall rendering.

How can I force the console to produce UTF-8 files, with a BOM if necessary?

I've already tried converting the template files that are used to bake the standard scaffolding pages, but with no luck.

damusnet
  • 4,320
  • 3
  • 25
  • 39

4 Answers4

1

The baked files are UTF-8, or rather, they only contain basic ASCII characters which are identical to the basic UTF-8 range, so can be regarded as either. It's Dreamweaver's problem, not a problem with bake. Check the Dreamweaver settings (or code in a decent editor ;-P).

You do not want to include a BOM, it'll screw you over later.

Community
  • 1
  • 1
deceze
  • 510,633
  • 85
  • 743
  • 889
1

I have the same problem - baked files are NOT UTF-8 but ASCII. (use notepad++ editor which allows easily convert, save files in another format).

Once bake generates files I have to convert them to UTF-8 one by one, to be able to work with Polish local characters.

I tried changing template files to UTF-8 but somehow this does not help. This may have something to do with the fact that the default file does not contain any non ascii character, therefore even if saved as UTF they stay ASCII.

The simplest way I found to overcome this is to modify template file eg. cake\console\templates\default\classes\model.ctp to include utf-8 character somewhere, e.g.: //'message' => 'Your custom message here ł', (notice last non ASCII character at the end of line. then converting and saving as UTF-8 makes sure template file is utf-8.

now, model files are generated as UTF-8.

lyba
  • 26
  • 1
1

Use the Bake_UTF8 plugin =]

http://www.github.com/pedroelsner/bake_utf8

I hope this be helpfull.

Pedro Elsner

0

Another way to achieve this is to open PHP files that are producing UTF-8 content (without BOM) and then saving them in format UTF-8 with BOM using Notepad++ (Encoding->Encode in UTF-8)

In my case I had Excel CSV file:

/patients/exportFirstReport/atskaite1-25-10-2013.csv

Then I had to convert encoding of PHP files down the stack:

\index.php
\app\Controller\PatientsController.php
\app\View\Patients\csv\export_first_report.ctp
\app\View\Layouts\csv\default.ctp

After conversion of encoding of these files it produces readable UTF8 excel files

Evalds Urtans
  • 6,436
  • 1
  • 41
  • 31