Re: [fpc-pascal] How to know the encoding of a string?

2016-10-18 Thread Marcos Douglas B. Santos
On Mon, Oct 17, 2016 at 2:47 PM, Bart  wrote:
> As explained there is no certain way.
> Lazarus comes with lconvencoding unit which has a guessencoding function.
> Maybe this can be of some help to you?

I'd not seen this unit before. Maybe this is the short way to do what
I wanna do.
Thanks.


Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to know the encoding of a string?

2016-10-18 Thread Marcos Douglas B. Santos
On Mon, Oct 17, 2016 at 11:21 AM, Graeme Geldenhuys
 wrote:
> No such function [with exact results] exists anywhere (no matter the
> programming language). The best programs can do is to interrogate the
> contents of a file and make a best guess.  How they do that
> interrogation -- I unfortunately don't know. I guess you could look at
> the source code of some of the open source text editors and see what
> they do. Some text editors are much better than others. eg: EditPad Pro
> (commercial) and jEdit (open source) are very good at these interrogations.

Thanks. I'll try http://chsdet.sourceforge.net (Jonas' tip).

> Alternatively, simply ask the person that supplies you with these files
> to tell you want encoding they use. They must know the answer.

It's not so simple... :)


Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to know the encoding of a string?

2016-10-18 Thread Marcos Douglas B. Santos
On Mon, Oct 17, 2016 at 11:19 AM, Jonas Maebe  wrote:
> There are some heuristics you could try to apply (see e.g.
> http://chsdet.sourceforge.net ), but in general it is impossible to know
> for sure what encoding has been used

Interesting project, I'll take a look, thanks.


Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to know the encoding of a string?

2016-10-17 Thread Bart
On 10/17/16, Marcos Douglas B. Santos  wrote:

> Is there a way to know what encoding was used at a string?
>
> My system are receiving some files and I don't know the encoding.
> I would like to know and then, convert it.

As explained there is no certain way.
Lazarus comes with lconvencoding unit which has a guessencoding function.
Maybe this can be of some help to you?

(Ruling out a string is UTF8 (compatible) can be done 100%)

Bart
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to know the encoding of a string?

2016-10-17 Thread Graeme Geldenhuys
On 2016-10-17 14:14, Marcos Douglas B. Santos wrote:
> My system are receiving some files and I don't know the encoding.
> I would like to know and then, convert it.

No such function [with exact results] exists anywhere (no matter the
programming language). The best programs can do is to interrogate the
contents of a file and make a best guess.  How they do that
interrogation -- I unfortunately don't know. I guess you could look at
the source code of some of the open source text editors and see what
they do. Some text editors are much better than others. eg: EditPad Pro
(commercial) and jEdit (open source) are very good at these interrogations.

Alternatively, simply ask the person that supplies you with these files
to tell you want encoding they use. They must know the answer.


Regards,
  Graeme

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

My public PGP key:  http://tinyurl.com/graeme-pgp
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] How to know the encoding of a string?

2016-10-17 Thread Jonas Maebe
Marcos Douglas B. Santos wrote:
> Is there a way to know what encoding was used at a string?
> 
> My system are receiving some files and I don't know the encoding.
> I would like to know and then, convert it.

There are some heuristics you could try to apply (see e.g.
http://chsdet.sourceforge.net ), but in general it is impossible to know
for sure what encoding has been used.


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] How to know the encoding of a string?

2016-10-17 Thread Marcos Douglas B. Santos
Hi,

Is there a way to know what encoding was used at a string?

My system are receiving some files and I don't know the encoding.
I would like to know and then, convert it.

Best regards,
Marcos Douglas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal