unicode filenames problem

This forum is about all development around libVLC.
innerspace
Blank Cone
Blank Cone
Posts: 28
Joined: 10 Aug 2008 22:47
VLC version: 0.8.6
Operating System: Windows / OsX
Location: Thailand & England

unicode filenames problem

Postby innerspace » 11 Dec 2008 10:05

Im having problems playing videos with non-ANSI (thai) filenames using 0.9.6 and Kairos's Interop wrapper.

When feeding a thai file into a new VlcMedia I can see the proper name passed in, but checking the VlcMedia properties on the next line of debugging shows ???? instead of the thai characters.

The problem appears to be due to libvlc_media_new using unmanagedtype.LPstr

This is a single byte ANSI string, whereas I need unicode to read thai characters.

I have tried building a new version of the Interop Wrapper using BStr, LPTStr and LPWStr but none of these function at all.

I know that unicode filename support is possible since VLC plays them fine, I just need to replicate that in .Net!

Any ideas?

Here is a bit of Thai text incase it helps with testing (แจ้งรายการ)

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: unicode filenames problem

Postby Kairos » 12 Dec 2008 06:55

Hmm... I think libvlc is using char* which is utf8 where C# is utf16. You would probably have to marshal it as a byte array

Code: Select all

[DllImport("libvlc")] internal static extern IntPtr libvlc_media_new(IntPtr p_instance, [MarshalAs(UnmanagedType.LPArray)] byte[] psz_mrl, ref libvlc_exception_t p_exception);
If you do this you need to encode the string before you pass it in like this;

Code: Select all

InteropMethods.libvlc_media_new(p_instance, System.Text.Encoding.UTF8.GetBytes(MRL) , ref p_exception);
This is just off the top of my head, I haven't tested it.

billy_mo
New Cone
New Cone
Posts: 7
Joined: 29 Oct 2008 13:08

Re: unicode filenames problem

Postby billy_mo » 15 Dec 2008 23:32

I've the same problem when programming in VC++. I have to convert the UTF16 string to UTF8 string using the WideCharToMultiByte function.

MidnightCoder
Blank Cone
Blank Cone
Posts: 82
Joined: 08 Aug 2008 06:04

Re: unicode filenames problem

Postby MidnightCoder » 07 Feb 2009 12:39

Can you explain the solution to fix this? I'm having the same issue.

MidnightCoder
Blank Cone
Blank Cone
Posts: 82
Joined: 08 Aug 2008 06:04

Re: unicode filenames problem

Postby MidnightCoder » 07 Feb 2009 13:31

Hmm... I think libvlc is using char* which is utf8 where C# is utf16. You would probably have to marshal it as a byte array

Code: Select all

[DllImport("libvlc")] internal static extern IntPtr libvlc_media_new(IntPtr p_instance, [MarshalAs(UnmanagedType.LPArray)] byte[] psz_mrl, ref libvlc_exception_t p_exception);
If you do this you need to encode the string before you pass it in like this;

Code: Select all

InteropMethods.libvlc_media_new(p_instance, System.Text.Encoding.UTF8.GetBytes(MRL) , ref p_exception);
This is just off the top of my head, I haven't tested it.
Confirmed that this method works. Thanks a bunch!


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 3 guests