On 08/23/2012 06:55 PM, Stefan Sperling wrote:
On Thu, Aug 23, 2012 at 05:32:51PM -0400, Geoff Steckel wrote:
Using iconv in an editor is EXTREMELY dangerous without complex precautions.
Given a file containing characters not valid in the current locale,
it will at minimum prevent viewing the file.
An editor needs to convert between character sets.
How else are you going to display a latin1 file in a UTF-8 locale,
for example?

If the current character set of the locale cannot display your file
because conversion from file source encoding to output encoding fails,
tough, you'll have display problems. What else is an application
supposed to do in this case? It's being asked to do something impossible.

BTW, vim links to libiconv. For some bizarre reason emacs links to
libossaudio instead ;)

If the file is written out, the file is destroyed.
IMnsHO, that is fatally flawed.
Well, yes, using a character set conversion API in stupid ways can
munge data. How does that relate to anything I was saying?
As long as iconv is only used to display data, not to change file
contents, you're perfectly right.

A real example is a L***x editor using iconv. Open a 5000 line file,
change line 100, line 500 contains a non-conforming character,
file is truncated there.

Not pretty.

Another real example. Bring up line containing non-conforming character.
Line appears blank.

I agree that it takes a great deal of care to implement a multi-character
set editor such that it works on all useful files while displaying in
a particular locale's character set.

Geoff Steckel

Reply via email to