BASS.NET API for the Un4seen BASS Audio LibraryUtilsIntPtrAsStringUtf8orLatin1 Method BASS.NET API for the Un4seen BASS Audio Library
Translates an IntPtr into a .NET managed string.

Sometime BASS returns an IntPtr which actually represents a pointer to a memory block containing either a null-terminated UTF-8 or Latin-1 *char (string, 8-bit). This method does this translation for you and returns the actual string.

Namespace: Un4seen.Bass
Assembly: Bass.Net (in Bass.Net.dll) Version:

public static string IntPtrAsStringUtf8orLatin1(
	IntPtr utf8Ptr,
	out int len


Type: SystemIntPtr
The IntPtr which represents the address of the first character of the unmanaged *char (string, Latin-1 or UTF-8, 8-bit).
Type: SystemInt32
Returns the number of bytes read (the length of the decoded string).

Return Value

Type: String
The translated unicode string.

Actually this method tries to encode the pointer to both UTF-8 and Latin-1. It returns the UTF-8 string if it is valid and shorter as it's Latin-1 counterpart.
See Also