public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* NLS: utf8 conversions
@ 2009-04-24 20:02 Alan Stern
  2009-04-27  8:09 ` Clemens Ladisch
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Stern @ 2009-04-24 20:02 UTC (permalink / raw)
  To: Kernel development list; +Cc: USB list

Although nobody seems to have made a big deal about it, the conversions
between utf8 and utf16 done by fs/nls/nls_base.c are wrong in a couple
of important respects:

	They don't handle Unicode code points larger than U+FFFF.

	They don't detect invalid values, in particular, surrogate
	code points.

The problems stem from the fact the characters at issue can't be
represented by a single 16-bit wchar_t.  But that's no excuse for
performing an incorrect conversion to or from utf16.

Are there any definite thoughts on how this should be handled?  I don't 
see any way for the single-character conversion routines (utf8_mbtowc 
and utf8_wctomb) to come to grips with these issues, except perhaps for 
returning an error when a character would be invalid or too big to fit 
in 16 bits.

The string-oriented routines (utf8_mbstowcs and utf8_wcstombs) could be 
adapted to deal with these issues properly.

Any comments or suggestions for other approaches?

Alan Stern


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-04-28 15:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-24 20:02 NLS: utf8 conversions Alan Stern
2009-04-27  8:09 ` Clemens Ladisch
2009-04-27 15:51   ` Alan Stern
2009-04-28  6:51     ` Clemens Ladisch
2009-04-28 15:51       ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox