NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
File Encoding mixed up


Joined: 16 Jun 2011
Posts: 31
Reply with quote
Hi, anyone else experiencing the following problem with file encoding in 15010?

1. Create a file in an empty folder with UTF8 encoding with following content
Code:
<?php
$string = str_replace(array("Ö", "Ü", "Ä", "ö", "ü", "ä","ß"), array("Oe", "Ue", "Ae", "oe", "ue", "ae","ss"), $string);
?>

2. Create a project based on that new directory. Set default encoding to ISO-8859-1
3. Goto the new project in your workspace and open that new file.
4. Et voila, the file obviously opens in ISO-8859-1 and the special chars now are shown wrongly encoded.
5. The thing is, when you change the file and save it, it will be correctly saved in UTF8 but it's shown in PHPEd as ISO.
PS: My global encoding is set to UTF8 but some projects written in ISO, therefore i use it like so for some projects.

Expected behaviour:
1. Existing files should always open with the actual encoding of the file, not with the encoding from the project.
2. New files should be created with the encoding choosen in project/global settings.
View user's profileFind all posts by brainSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
Encoding works per files.
If you open a file that was NEVER open in PhpED, the IDE will try to use encoding indications (such as BOM or charset meta in html), and if they are not found, it will fallback to the project setting.
Note, that you can set different encodings in different project directories.
If you open a file that was PREVIOUSLY open in PhpED, the IDE will use encoding that was used last time.

In your case -- if you opened or created a file in UTF8, IDE will open it in UTF8 regardless what you set in the project.

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 16 Jun 2011
Posts: 31
Reply with quote
In this case i've created a file outside PHPEd.
So, there is no way to avoid this problem?
The thing is, it saves the file correctly in UTF8 but PHPEd shows it with ISO - So PHPEd know the file format because it can save it, but it doesn't display correctly.
When i do the same thing in for example Notepad++, this works fine and file encodings are always match perfectly, regardless if you have opened/created the file before with NP++.
In my opinion this is a bug, isn't it?

The use case is, and i'm sure that this is very often like so:
1. You have a big, older, project, mixed up with different file encoding.
2. You just start coding in it with PHPEd - No chance to find out in PHPEd which file encoding the file really have?
View user's profileFind all posts by brainSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8334
Reply with quote
There are two ways to change encoding without changing content of the file:
-open file using File->Open and pick correct encoding in the dialog
-change encoding in the status bar, then re-open the file (w/o saving it)

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 16 Jun 2011
Posts: 31
Reply with quote
Both suggestions work but for me that is just a workaround.
If you have many files in your projects it's a little bit annoying when nusphere show a wrong file encoding.
I would be very happy to see a better file encoding mechanism that show the correct file encoding without manual overrides.
It's possible, that show us Notepad++
It's also open source so maybe get some ideas from that source?!
View user's profileFind all posts by brainSend private message
File Encoding mixed up
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic