tags:

views:

27

answers:

1

Hi,

I have follow code to make a String to a CFString:

 internal static byte[] StringToCFString(string value)
    {
        byte[] b;

        b = new byte[value.Length + 10];
        b[4] = 0x8c;
        b[5] = 07;
        b[6] = 01;
        b[8] = (byte)value.Length;
        Encoding.ASCII.GetBytes(value, 0, value.Length, b, 9);
        return b;
    }

    public static byte[] StringToCString(string value)
    {
        byte[] bytes = new byte[value.Length + 1];
        Encoding.ASCII.GetBytes(value, 0, value.Length, bytes, 0);
        return bytes;
    }

How I can get a CFString to String back? (C#.Net 2.0)

+1  A: 

I would try something like this...

Encoding.ASCII.GetString(value, 9, value.Length - 9);
Flesrouy