Page 1 of 1

Support for APIs that require non-native string types.

Posted: Wed Dec 09, 2015 1:04 pm
by mikejs
From discussion in this thread: http://www.purebasic.fr/english/viewtop ... 13&t=64232

For some APIs, it is necessary to pass strings of a particular format, which may differ from the native PB format. Where a string is a simple parameter to a function, we can use the pseudotypes and declare the function as taking a particular string format, and that works well.

In other cases we need to pass, say, an array of strings of a particular type, and this currently doesn't work well at all.

e.g. parts of the LDAP SDK require an array of UTF8 strings containing the list of attributes you're interested in reading. Other APIs have similar cases. There are probably also cases where we need to pass structures containing strings in formats that differ from PB native, although I've not run into that as yet.

It would be useful in such cases to be able to declare an array of UTF8 strings, rather than having to pass a block of memory that's been constructed by a more manual process, or poking UTF8 format strings into an array. The latter can work in some cases, but because PB is interpreting the contents of those strings as UCS2, you can't usefully log them without jumping through further hoops.

What's the best native solution for dealing with APIs that require arrays of non-native strings?