Hello all.

Unlike posix systems windows defines charsets for filesystem.
Native OS routines (that deal with any strings, not only file names)
come in two flavors, one that use old-school 1 byte strings
and the second that uses UTF-16 (or something like this) strings.

These functions are suffiixed with either A (ansi) or W (wide).
For example there are CreateFileA and CreateFileW.

Native character set for all modern systems is UTF-16.
So all A variants are implemented as wrappers
that convert strings back and forth and call W functions.

All native applications are usually deal with W functions.
A flavors are mostly for legacy code.

Character set that is used for A functions is called
"Language for non-Unicode programs"
and it is configured per system.

msvcrt.dll (that is used in mingw as replacement for libc)
also has similar structure.

There are, for example, fopen() that is implemented via CreateFileA
and _wfopen() that is implemented via CreateFileW.

Here comes the problem with file handling.
Since MPD uses standard fopen(), stat(), etc functions
it deals with 1-byte characters.

AFAIK without configuring filesystem_charset MPD sees only ascii file names.
For example to see russian bands I need to set charset to "cp1251".
However to see german bands I need to set it to "cp1252"
There is no way see all bands simultaneously, except renaming the files.

Fortunately, this is a well known porting problem.

glib provides its own equivalents of file APIs like g_fopen(), g_stat() 
and so on.
On all systems (except win32) these functions simply recall native ones.
On win32 they assume that file name is UTF-8, convert it to UTF-16
and then call W variant of the function.

Most glib variants are completely identical
so porting to them is a simple search-n-replace act.

As far as I can see the only difference is 
opendir(),readdir(),closedir() functions.
glib equivalents are slightly different in names and syntax, but 
functionally identical.

If we could do such porting (we already heavily rely on glib everywhere),
there will be no need to configure file system charset on win32
and these file name handling issues will go away.

However, this affects MPD on other platforms, so I want to discuss this 
change
before starting the work.

--
Denis







------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Musicpd-dev-team mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to