View Full Version : Help with character set issues ?

2007-05-28, 22:48
I have a problem with character set. I just realized that the paths stored in the url column in the tracks table will have different contents on Linux and Windows.

On Linux the swedish characters едц is represented in the url column as:

But on Windows the same characters is represented as:

The problem comes when I want to do a database query which searches in the url column, this query have to look different o Linux compared to Windows.

It doesn't make any difference which locale I run SlimServer on, at least not on Linux, the database contents is the same.

I read the actual query from a file, and everything works if I on linux before I execute it do:
$query = Slim::Utils::Unicode::utf8off($query);
To make the same thing work on Windows I instead have to do:
$query = Slim::Utils::Unicode::utf8on($query);

I have no idea if this is actually how I'm supposed to do it, but I have found it works with trial and error.

I guess the cause of the problem is that the file system probably uses different character encoding on Windows and Linux.

Does anyone have an idea how I can make this code platform independent ?

2007-05-30, 22:15
Is there some way I can detect which encoding the filenames in the file system have ?

Dan Sully
2007-05-30, 22:22
* erland shaped the electrons to say...

>Is there some way I can detect which encoding the filenames in the file
>system have ?

Not easily. See Slim::Utils::Unicode.

The issue is that while LANG or the codepage my be set to one thing, the byte
representation on the filesystem can be another.

Adobe Photoshop - When you want the truth. Real bad.