Char * handling in C # (strlen function?)

I am dealing with char * in C # code (in an insecure section). Is there a way to call the strlen function from C #. Against all common sense, it's worth writing a custom strlen function to search for a null terminator. There is no way to call strlen from C # or a similar method that I have access to?

In the big picture I am trying to convert char * to a string object, but the characters are in ANSCII format, so I will use the .NET Encoding.Convert namespace to convert it. But I need to know the length of the string before I do this.

+3
source share
1 answer

Marshal.PtrToStringAnsi() does exactly what you need:

, .

, lstrlenA , kernel32.dll. , "get me the length of this unmanaged string".

+5

All Articles