[vlc-devel] [PATCH 1/2] lua: add a guess_encoding function to convert Latin1 to UTF8
remi at remlab.net
Tue Aug 27 19:09:38 CEST 2013
Le mardi 27 août 2013 18:42:52 Ludovic Fauvet a écrit :
> On 08/27/2013 06:09 PM, Rémi Denis-Courmont wrote:
> > Le mardi 27 août 2013 18:04:05 Edward Wang a écrit :
> >> On Tue, Aug 27, 2013 at 5:45 PM, Rémi Denis-Courmont <remi at remlab.net>
> > wrote:
> >>> I only ever challenged the solution, not the problem.
> >> As I understand it, you are simply opposed to exposing a new C
> >> function to perform this?
> > I am opposed to adding a special function that just calls two functions
> > that already exist in Lua.
> Why did you not say this in the first place?
Who are you trying to fool here? You said you needed IsUTF8() functionality in
Lua to discriminate UTF-8 from Latin-1.
| There is no point in doing this. from_charset already provides all that's
| needed (and is much sounder architecturally).
And then I wrote:
| [from_charset()] returns an empty string on error, which is clearly
| different from success. Feel free to change it to return a proper error or
If I had phrased it in high level architectural terms, you would have -
rightfully- accused me of being vague, partial or what not.
> I don't get why it's so hard to communicate with you…
And one more ad hominem today.
> >> It makes sense to do this in C, as every string in Lua should be UTF8.
> >> This would improve the architecture by sanitizing non-UTF8 strings
> >> from the Lua interface altogether.
> > Then from_charset() should be removed too. Oops.
> Of course it would be better to not having to deal with encoding at all.
> >> Other lua scripts in the future might have to demux non-UTF8 as well,
> >> and this function would be highly useful in those cases too.
> > And that is why we have from_charset() *already*. Plus from_charset()
> > supports not only Latin-1, but any character set that LibVLC ships.
> Deporting the complexity into the lua extensions is _not_ the best way
> to promote them.
Oh I see you fished one big red herring there.
I really do not think that one call to a function that detects UTF-8 and falls
back to Latin-1 under the name vlc.string.guess_encoding() is simpler than two
calls to vlc.string.from_charset() with UTF-8 and ISO-8859-1 named explicitly.
There is more to code complexity than the number of function calls to be made.
> Then I'm sorry, I thought that Lua was meant to extend VLC easily
> without having to care about low-level stuff.
Nice troll attempt.
The Lua playlist and SD were meant to avoid tedious and bug-prone C
string/memory manipulations. I fail to see how character encoding is a
characteristic of C as opposed to other programming languages.
More information about the vlc-devel