[Done] UTF8 / Plain text file format
-
- PureBasic Expert
- Posts: 2810
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
[Done] UTF8 / Plain text file format
The problem still persists, if i create a form and set it to be plain text, and if then i switch between form view / code view the editor changes the encoding to UTF8 and messes up all latin characthers ...
This is a pain, because there is no warning the encoding changed, and i have to manually reedit all labels to latin (ç ã ó etc) (not funny has the project now passes 150.000 lines of code)
This is a pain, because there is no warning the encoding changed, and i have to manually reedit all labels to latin (ç ã ó etc) (not funny has the project now passes 150.000 lines of code)
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: UTF8 / Plain text file format
The Form Designer does not really support any editing other than the re-arrangement and add/delete of gadgets, so the best way forward is to use From Designer to design the basic layout of the form, and from there code the details by hand (which means you can't later use the Designer, but that is by no means a disaster, it's already done the bulk of the work).
Also, think about using Unicode by default anyway! Microsoft, Adobe and Apple have worked very hard (together!) to ensure that you can, because it is the best possible way to use text in your apps.
Also, think about using Unicode by default anyway! Microsoft, Adobe and Apple have worked very hard (together!) to ensure that you can, because it is the best possible way to use text in your apps.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
-
- PureBasic Expert
- Posts: 2810
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
Re: UTF8 / Plain text file format
My problem is not unicode, it is the fact the Form Designer saves in ASCII by default and that messes up UTF8 projects.
Most users don't see this bug, because it is only visible when using Latin or an encoding other then ascii.
Example for dummies:
I created this simple GUI and saved normally (IDE file format confirmed has: Utf8)
I open this fresh file in notepad++ and it is ASCII, not UTF8 has it should be!
Now, i go to the IDE, change the form to code view and check File Format -> Encoding: ASCII and back to Encoding: UTF8, this is the result:
Now the file is saved has UTF8 (has it should have been since start), but the gadget descriptions encoding are all *** up ...
And the problem is this happens automatically if i have the misfortune of opening the pbf file by mistake...
Most users don't see this bug, because it is only visible when using Latin or an encoding other then ascii.
Example for dummies:
I created this simple GUI and saved normally (IDE file format confirmed has: Utf8)
Code: Select all
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
Enumeration FormWindow
#Window_0
EndEnumeration
Enumeration FormGadget
#Button_0
#Button_1
#Button_2
#Text_0
#Text_1
#Text_2
EndEnumeration
Procedure OpenWindow_0(x = 0, y = 0, width = 365, height = 105)
OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu)
ButtonGadget(#Button_0, 230, 15, 100, 25, "aáàâä")
ButtonGadget(#Button_1, 125, 15, 100, 25, "oóòõö")
ButtonGadget(#Button_2, 15, 15, 100, 25, "aáàâä")
TextGadget(#Text_0, 20, 50, 100, 25, "oóòõö")
TextGadget(#Text_1, 235, 50, 100, 25, "aáàâä")
TextGadget(#Text_2, 125, 50, 100, 25, "aáàâä")
EndProcedure
Now, i go to the IDE, change the form to code view and check File Format -> Encoding: ASCII and back to Encoding: UTF8, this is the result:
Code: Select all
Enumeration FormWindow
#Window_0
EndEnumeration
Enumeration FormGadget
#Button_0
#Button_1
#Button_2
#Text_0
#Text_1
#Text_2
EndEnumeration
Procedure OpenWindow_0(x = 0, y = 0, width = 365, height = 105)
OpenWindow(#Window_0, x, y, width, height, "", #PB_Window_SystemMenu)
ButtonGadget(#Button_0, 230, 15, 100, 25, "aÀ¡À À¢À¤")
ButtonGadget(#Button_1, 125, 15, 100, 25, "oÀ³À²ÀµÀ¶")
ButtonGadget(#Button_2, 15, 15, 100, 25, "aÀ¡À À¢À¤")
TextGadget(#Text_0, 20, 50, 100, 25, "oÀ³À²ÀµÀ¶")
TextGadget(#Text_1, 235, 50, 100, 25, "aÀ¡À À¢À¤")
TextGadget(#Text_2, 125, 50, 100, 25, "aÀ¡À À¢À¤")
EndProcedure
And the problem is this happens automatically if i have the misfortune of opening the pbf file by mistake...
-
- Always Here
- Posts: 6425
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: UTF8 / Plain text file format
Well, you have effectively stated the opposite of your original post:
Certainly agree, the Form Designer should in any case default to Unicode, but you can avoid inputting text at form design stage - just add it later.the editor changes the encoding to UTF8
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
- majikeyric
- Enthusiast
- Posts: 181
- Joined: Mon Oct 21, 2013 5:21 pm
- Location: France
- Contact:
Re: UTF8 / Plain text file format
I encountered this problem too... What a pain...
Re: [Done] UTF8 / Plain text file format
The actual problem is that Form Designer, when used in graphical mode, saves files in UTF8 WITHOUT BOM. Then the compiler do not understand the file is in UTF8 and the labels and texts of the gadgets are corrupted.
Last edited by Niffo on Thu Oct 22, 2015 5:50 pm, edited 1 time in total.
Niffo
Re: [Done] UTF8 / Plain text file format
Good finding, I will take a closer look.
Re: [Done] UTF8 / Plain text file format
From many times, I use Form Designer with accents (in texts, not in labels) in graphic mode with success.
The solution I use is to switch Forms in code mode before compile/start
(my files format is always utf-8 and I never write anything directly in code)
Work fine
(For Fred, in v.o, because my english spoken is poor J'ai cherché aussi pendant un certain temps ce problème d'accents et fini par me rendre compte qu'on peut très bien utiliser des accents avec le form designer en mode graphique, à condition de repasser en mode code au moment de lancer / compiler. À défaut de réencoder, il est peut être possible de forcer cette 'bascule' avant compilation?)
The solution I use is to switch Forms in code mode before compile/start
(my files format is always utf-8 and I never write anything directly in code)
Work fine
(For Fred, in v.o, because my english spoken is poor J'ai cherché aussi pendant un certain temps ce problème d'accents et fini par me rendre compte qu'on peut très bien utiliser des accents avec le form designer en mode graphique, à condition de repasser en mode code au moment de lancer / compiler. À défaut de réencoder, il est peut être possible de forcer cette 'bascule' avant compilation?)
Re: [Done] UTF8 / Plain text file format
Sorry about this
I'll probably leave it to Fred as I'm not very good with file encoding stuff! (sorry Fred!!)
I'll probably leave it to Fred as I'm not very good with file encoding stuff! (sorry Fred!!)
-
- PureBasic Expert
- Posts: 2810
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
Re: [Done] UTF8 / Plain text file format
[TWITCH voice] It's me [\TWITCH voice]
PB 5.31 this time
I have found another bug with UTF8 with purebasic editor and form designer...
Purebasic Editor file encoding is UTF8 (perfect)
Purebasic Form designer file encoding is UTF8 without BOM (latin characters get all messed up on the executable)
My solution for now is open .pbf files in notepad++ and convert the encoding to UTF8
Thank you all for your hard work!
PB 5.31 this time
I have found another bug with UTF8 with purebasic editor and form designer...
Purebasic Editor file encoding is UTF8 (perfect)
Purebasic Form designer file encoding is UTF8 without BOM (latin characters get all messed up on the executable)
My solution for now is open .pbf files in notepad++ and convert the encoding to UTF8
Thank you all for your hard work!
Last edited by Num3 on Tue Mar 03, 2015 12:56 pm, edited 1 time in total.
Re: [Done] UTF8 / Plain text file format
Yes, already said in my postNum3 wrote:Purebasic Form designer file encoding is UTF8 without BOM (latin characthers get all messed up on the executable)
Or you can just toggle to "Code view" and saveNum3 wrote:My solution for now is open .pbf files in notepad++ and convert the encoding to UTF8
Niffo
-
- PureBasic Expert
- Posts: 2810
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
Re: [Done] UTF8 / Plain text file format
Upss missed it I was speed reading!Niffo wrote:Yes, already said in my post
Ah, them tips&tricks!Niffo wrote:Or you can just toggle to "Code view" and save
So the bug only happens when the form is saved while in editing mode! <- HINT HINT