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

Mailing lists / fpc-pascal / 2016-10
7 messages · 4 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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
Marcos Douglas B. Santos wroteIs 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
Is there a way to know what encoding was used at a string? My system are receiving some…
Marcos Douglas B. Santos wroteMy 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
Is there a way to know what encoding was used at a string? My system are receiving some…
Marcos Douglas B. Santos wroteIs 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
There are some heuristics you could try to apply (see e.g. http://chsdet.sourceforge.net…
Jonas Maebe wroteThere 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
No such function [with exact results] exists anywhere (no matter the programming…
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
As explained there is no certain way. Lazarus comes with lconvencoding unit which has a…
Bart wroteAs 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