[Mono-devel-list] RE: patch for: Non ASCII charactersinfilenames/ command line parameters

Dick Porter dick at ximian.com
Sat Oct 25 08:53:28 EDT 2003


On Thu, 2003-10-23 at 11:15, Jörg Rosenkranz wrote:
> The filename needs to be in the encoding configured on the user's 
> system. We have no chance to avoid filenames with non ASCII 7 chars,
> and there is also no chance to push the users to using UTF8 as encoding.
> If the user creates an directory named "Müller" using our system he
> doesn't see "Müller" when he accesses it using Samba or directly.
> So this behaviour is exposed to the user.

Try this patch.  If it does what you need, then I will commit it.

This will make mono default to reading and writing UTF8 strings, but
will consult the colon-separated list held in MONO_EXTERNAL_ENCODINGS
for fallback encodings when reading cmdline args and directories, and
creating files.  The items in MONO_EXTERNAL_ENCODINGS should be
identifiers known to iconv (via glib), or the special case
"default_encoding" which will use the locale's encoding.  The first
encoding that can be successfully turned into utf8 or utf16 stops the
search.

Eg: 

[dick at leviathan mono] [ 1:47PM] 
:; LANG=en_GB ls /tmp/xxx*
ls: /tmp/xxx*: No such file or directory

[dick at leviathan mono] [ 1:48PM]  Exit code: 1
:; LANG=en_GB MONO_EXTERNAL_ENCODINGS=default_locale mono /tmp/filecreate.exe /tmp/xxxwïbble

[dick at leviathan mono] [ 1:48PM] 
:; LANG=en_GB ls /tmp/xxx*
/tmp/xxxwïbble            


I chose not to use the glib "broken" filename variable, as it's just not
flexible enough.

Miguel wrote:
> > I have the same situation here, Red Hat 9 changed the defaults to do
> > UTF-8 encoding, but all my existing files are using latin1 
> > encoding, so
> > it is pretty ugly.
> 
> This is a problem until there is a encoding standard used by all
> distributions. Until then we have to live with that problem :-|

I've CC'd Michael Meeks, as he might want to look at the issue again for
glib.  (Michael - the interesting part for you is in
mono/utils/strenc.c.)

- Dick


-------------- next part --------------
A non-text attachment was scrubbed...
Name: encdiffs
Type: text/x-patch
Size: 17933 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20031025/29658267/attachment.bin 


More information about the Mono-devel-list mailing list