Recent

Author Topic: ISO-8859-1 in GTK2 (linux)  (Read 3997 times)

chrnobel

  • Sr. Member
  • ****
  • Posts: 283
ISO-8859-1 in GTK2 (linux)
« on: October 06, 2008, 11:10:54 am »
I am making a web application with POWtils, where I am going to use ISO-8859-1, so I am 100% sure that the data entered on the website, and then stored in my MySQL database is in a format where data can easily be exported to another database running on Windows.

As this Windows application is not UTF, I am not interested in converting data when exporting (also some Delphi programs needs access to the database, and as thise are written in D5, and I am not interested in buying a new Delphi, this makes some restrictions).

So therefore I am stuck with 8859, as the webpage also shall be able to handle Danish characters like æøå.

My problem is now that if I want use Lazarus with GTK2 it is not possible to edit 8859 (even if i have my locales set to da_DK.ISO-8859-1), but if I use GTK1 it is possible - however I prefer GTK2 because the interface is much nicer, and I do not want to recompile back and forth everytime I switch between making a GUI and a non GUI application.

If I use an external editor like Bluefish one can easily switch whether the document shall be in UTF or 8859, but this facility lacks in Lazarus' editor (and as I like code completion, using Bluefish is not at way to go).

So does anyone have a suggestion how to solve this problem.

Regards
Chris

dav999

  • New Member
  • *
  • Posts: 16
ISO-8859-1 in GTK2 (linux)
« Reply #1 on: October 20, 2008, 09:22:05 pm »
Hello,

my english is not very good, but if i have understand your request, you can test this code to converting a textfile in 8859 to utf :

i'm in ubuntu and this code works :
"chemin_du_fichier" is a global variable i store in the path of my file

Code: [Select]
var Aprocess : Tprocess;
    Astringlist : Tstringlist;

begin

//içi on va vérifier que le fichier est bien en encodage ISO-8859 (version windows)
//dans ce cas on va le convertir avec le prog "recode" en UTF-8 (ce qui évite d'avoir
//les erreurs de convertion windows/linux

   AProcess := TProcess.Create(nil);

   AStringList := TStringList.Create;

   //ATTENTION à bien mettre les trema sinon il y aura un message d'erreur car les chemins
   //avec un espace ne seront pas bien reconnus !!!!

   AProcess.CommandLine := 'file "' + chemin_du_fichier + '"';

   AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];

   //showmessage(aprocess.CommandLine);

   AProcess.Execute;

   AStringList.LoadFromStream(AProcess.Output);

   AProcess.Free;

   AProcess := TProcess.Create(nil);
   AProcess.Options := AProcess.Options + [poWaitOnExit];
   
   //showmessage(astringlist.Text);
   if findpart('8859-15',astringlist.Text) <> 0 then
     begin
     AProcess.CommandLine := 'recode iso-8859-15..utf-8 "' + chemin_du_fichier + '"';
     AProcess.Execute;
     end
    else if findpart('8859 t',astringlist.Text) <> 0 then
     begin
     AProcess.CommandLine := 'recode iso-8859..utf-8 "' + chemin_du_fichier + '"';
     AProcess.Execute;
     end;

     AProcess.Free;

   AStringList.Free;

end;


Bye
David
Ubuntu 8.04 - Lazarus 0.9.26 - FPC 2.2.2

chrnobel

  • Sr. Member
  • ****
  • Posts: 283
ISO-8859-1 in GTK2 (linux)
« Reply #2 on: October 21, 2008, 08:34:07 am »
Hi David.

No the problem is not just converting a textfile, that is relatively straight forward.

The problem is that the IDE in it self is (now) pure UTF8, which is ok in many situations, but as I am making an application that shall work together with other Windows programs (which still is sooo primitive with regards to UTF), it requires everything to be ISO-8859-1, including the editor of the IDE.

/Chris

dav999

  • New Member
  • *
  • Posts: 16
ISO-8859-1 in GTK2 (linux)
« Reply #3 on: October 21, 2008, 09:11:17 am »
ok, excuse for my response
your problem is harder that i think
Ubuntu 8.04 - Lazarus 0.9.26 - FPC 2.2.2

chrnobel

  • Sr. Member
  • ****
  • Posts: 283
ISO-8859-1 in GTK2 (linux)
« Reply #4 on: October 21, 2008, 10:46:00 am »
Hi David.

You don't have to excuse  :) , it is of course very positive with all kind of replies, and your suggestion can be usefull in other scenarios.

/Chris

 

TinyPortal © 2005-2018