[vlc-devel] [PATCH 1/2] lua: add a guess_encoding function to convert Latin1 to UTF8
Rémi Denis-Courmont
remi at remlab.net
Tue Aug 27 19:20:13 CEST 2013
Le mardi 27 août 2013 19:14:38 Edward Wang a écrit :
> On Tue, Aug 27, 2013 at 7:09 PM, Rémi Denis-Courmont <remi at remlab.net>
wrote:
> > I really do not think that one call to a function that detects UTF-8 and
> > falls back to Latin-1
>
> IsUTF8 ( psz_input ) ? strdup ( psz_input ) : FromLatin1 ( psz_input );
>
> If input string is UTF8
> -> return said string [implies string is UTF8 by IF statement]
> else [implies string is NOT UTF8]
> -> return said string converted to UTF8
> IsUTF8 ( psz_input ) ?
>
> I don't see where the "falling back" is?
That is falling back to Latin-1 encoding (FromLatin1()) from UTF-8 encoding
(strdup()) if the sequence pass UTF-8 validation (IsUTF8()).
(Note that any byte sequence is valid Latin-1.)
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list