Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Using char[] in C

Moderators: larsivi kris

Posted: 03/10/10 16:13:27

Hi!

I've got the problem that I want to pass file paths to a C library. This works fairly well with toStringz, as long as there are no UTF-8 code points. It chokes on stuff like "Trüby Trio" for example. Is there a simple way to convert the strings? I'm looking through the sources for 2 hours now and I can't find anything.

-Mike

Author Message

Posted: 03/10/10 16:31:07

Convert to what, though? To a CodePage? of some variety?

Posted: 03/10/10 17:59:07

Ah ... I have totally forgotten about codepages ...

This is what I'm using:

http://www.mega-nerd.com/libsndfile/api.html#open

Funny thing is I wrote a paragraph, looked into the lib's source to look up something because I wasn't sure and found that it exports a "sf_wchar_open" function on Windows which works with tango.text.convert.toString16. Problem solved for one OS :)

Thinking about it it's not a good idea to convert "down" to some pre-Utf encoding anyway.

-Mike

Posted: 03/10/10 18:16:13

yeah; with windows, you might find tango.sys.win32.CodePage? to be useful ... but that aside, it seems best to avoid codepages where feasible