Recent

Author Topic: Synedit problem using unicode  (Read 5884 times)

carmarri

  • Newbie
  • Posts: 6
Synedit problem using unicode
« on: January 14, 2010, 04:21:59 pm »
Hello,

I'm trying to use Synedit on my project because I want an automatic highlight for html documents. The problem I found is that qhen I use special characters, despite I enable the option UNICODE, It still displays question marks "?"

I found on internet a Unicode SynEdit package:
http://mh-nexus.de/en/unisynedit.php
But I don't know how to create a lpk file for that project.

I've found some messages of people having the same problem but not any solution.

Please, could anyone help me?

Thanks very much,
Carles

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: Synedit problem using unicode
« Reply #1 on: January 14, 2010, 04:56:22 pm »
HTML Documents should have a meta charset tag like this
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

read this value (here ISO-8859-1)  and convert it to EncodingUTF8 with unit LConvEncoding:
function ConvertEncoding(const s, FromEncoding, ToEncoding: string): string;   

carmarri

  • Newbie
  • Posts: 6
Re: Synedit problem using unicode
« Reply #2 on: January 15, 2010, 10:20:11 am »
Hello,

Thank you very much for your help. It worked for me:

    Try
        AssignFile(fp, UTF8ToSys(filepath));
        Reset(fp);
        while not eof(fp) do begin
          ReadLn(fp,auxstr);
          fEditor.SynEdit1.Lines.Add(ConvertEncoding(auxstr, 'ISO-8859-1', 'UTF8'));
        end;
        CloseFile(fp);
      except
        MessageDlg('Unable to read the file!', mtWarning, [mbYes], 0);
        exit;
      end;

I really appreciate all the contributions on this forum.
Carles

 

TinyPortal © 2005-2018