[Mono-list] Why UTF-16 strings in Mono.Unix?

Florian Weimer fw at deneb.enyo.de
Tue Oct 18 03:58:14 EDT 2005

* Jonathan Pryor:

> On Mon, 2005-10-17 at 19:03 +0200, Florian Weimer wrote:
>> Why are UTF-16 strings used in Mono.Unix?  Doesn't this mean that some
>> resources are inaccessible to programs running under Mono in a
>> multibyte localeq (such as one using UTF-8)?
> Care to elaborate?  System.String is always used to represent strings in
> Mono.Unix and Mono.Unix.Native, but Mono's marshaler will convert the
> strings to UTF-8 for the P/Invoke call.

UNIX systems do not have a system-wide locale.  Some user might run
under a single-byte locale and create a file named "Ärger.txt" (whose
name consists of exactly nine bytes in his locale).  Another user who
uses UTF-8 cannot access this file using any name that is valid UTF-8.
For applications written in C, this is typically not a problem because
you can pass the necessary byte string on the command line (entering
?rger.txt in the shell, which performs expansion), but this won't work
with Mono applications.

A first step in a direction to fix that would be to use native strings
(multibyte strings) for accessing native APIs.

More information about the Mono-list mailing list