Author Topic: Can project has a "encoding" property?  (Read 15653 times)

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Can project has a "encoding" property?
« on: August 23, 2009, 06:29:13 am »
Can project has a "encoding" property?

when I create a new class by "File->New->Class", the Wizards create new cpp and header files, but they are allways encoding with "system default". I have to change the encoding to "utf-8". can the class wizard set the files encoding after read the setting from project or the global setting?

mariocup

  • Guest
Re: Can project has a "encoding" property?
« Reply #1 on: August 23, 2009, 09:28:57 am »
Set the encoding in the menu settings->editor in the general settings choose "Use encoding when opening files" UTF-8.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Can project has a "encoding" property?
« Reply #2 on: August 23, 2009, 01:09:35 pm »
Set the encoding in the menu settings->editor in the general settings choose "Use encoding when opening files" UTF-8.
That will not work, because C::B first creates the file and than runs encoding-detection on it.
The file is an ascii-file and in the moment C::B uses the system-default for ascii-files, but I think the user-chosen encoding make more sense here, because it should be possible to open pure ascii files with almost any encoding.

Fixed in svn r5737

mariocup

  • Guest
Re: Can project has a "encoding" property?
« Reply #3 on: August 23, 2009, 03:12:28 pm »
Hi Jens,

I am working under windows and the system default is CP1252. I have configured in the CB editor UTF-8 for opening files and if I create a File->New->Class and save the files then the status bar shows UTF-8 encoding for these files too.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Can project has a "encoding" property?
« Reply #4 on: August 23, 2009, 03:24:45 pm »
Fixed in svn r5737
...including the removal of the System Locale as fallback?! IIRC we has re-implemented this because for many users this was the only working solution. Stay tuned that we'll receive the same complaints again, now. What's wrong with trying the system locale? I mean: It's a wx function that usually works just fine...?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Can project has a "encoding" property?
« Reply #5 on: August 23, 2009, 03:33:04 pm »
Fixed in svn r5737
...including the removal of the System Locale as fallback?! IIRC we has re-implemented this because for many users this was the only working solution. Stay tuned that we'll receive the same complaints again, now. What's wrong with trying the system locale? I mean: It's a wx function that usually works just fine...?!
No !

I only changed the behaviour, if the text was detected as pure (7-bit) ascii.

In this case we should not use the system-defrault, but the encoding, the user has chosen as default to open files.
Pure ascii-texts can be opened with any encoding, so it's not a problem.

The fallback to system-default, happens in ConvertToWxStr.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Can project has a "encoding" property?
« Reply #6 on: August 23, 2009, 03:45:19 pm »
Hi Jens,

I am working under windows and the system default is CP1252. I have configured in the CB editor UTF-8 for opening files and if I create a File->New->Class and save the files then the status bar shows UTF-8 encoding for these files too.
I tested in under both linux and windows, in both cases, I get a file in sytem-encoding (cp1252) instead of the encoding I chose in the editor-settings (utf-8).

That's a wrong behaviour in my opinion.
If we give the user the possibility to chose his preferred encoding for opening files, we should respect it (if possible), not only as fallback, but also as default for files that can be saved in (aömost) any encoding.

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: Can project has a "encoding" property?
« Reply #7 on: August 23, 2009, 04:02:09 pm »

mariocup

  • Guest
Re: Can project has a "encoding" property?
« Reply #8 on: August 23, 2009, 06:44:38 pm »
Hi Jens,

I am working under windows and the system default is CP1252. I have configured in the CB editor UTF-8 for opening files and if I create a File->New->Class and save the files then the status bar shows UTF-8 encoding for these files too.
I tested in under both linux and windows, in both cases, I get a file in sytem-encoding (cp1252) instead of the encoding I chose in the editor-settings (utf-8).

That's a wrong behaviour in my opinion.
If we give the user the possibility to chose his preferred encoding for opening files, we should respect it (if possible), not only as fallback, but also as default for files that can be saved in (aömost) any encoding.

I tested it with the cc_completion branch and there CB behaves like you are saying. But I tried it with a former CB revision 5463, which I am using too, and in this version CB behaves like I described before.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Can project has a "encoding" property?
« Reply #9 on: August 23, 2009, 06:51:20 pm »
I tested it with the cc_completion branch and there CB behaves like you are saying. But I tried it with a former CB revision 5463, which I am using too, and in this version CB behaves like I described before.

That's why they behave different, 5463 was before the wxAuiNotebook merge and some parts of the encoding-detection behave different there.
For some reasons (don't ask me why), I decided to use system-default for pure ascii.

That was the wrong (or at least not best) way, as I think today.

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Can project has a "encoding" property?
« Reply #10 on: August 23, 2009, 08:27:59 pm »
The fallback to system-default, happens in ConvertToWxStr.
...alright. I just looked at the patch which made me think so. :roll:
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: Can project has a "encoding" property?
« Reply #11 on: August 29, 2009, 05:18:04 pm »
...For some reasons (don't ask me why), I decided to use system-default for pure ascii.

OH, no! pls.

when I create a new cpp file, it usually has pure ascii only. so, it was "system-default" encoding. and once I input a Chinese character into it, I have to modify it's encoding to utf8 by manual (since i hope all files in the project use utf-8).

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Can project has a "encoding" property?
« Reply #12 on: August 29, 2009, 05:26:33 pm »
...For some reasons (don't ask me why), I decided to use system-default for pure ascii.

OH, no! pls.

when I create a new cpp file, it usually has pure ascii only. so, it was "system-default" encoding. and once I input a Chinese character into it, I have to modify it's encoding to utf8 by manual (since i hope all files in the project use utf-8).

As I wrote before, I changed that behaviour to use the user chosen default encoding for opening files.
From my todays point of view I don't know why I chose system-default before  :oops: