Click here to Skip to main content
14,733,889 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i m converting the char in string

\0\0\0\0\0\0\0\0??;\b\0\0\0\0?????qUw?g?\u0001\0\0\0\0 its not humman readable data.

so what will be do for write Data
i want this type of data 2018-03-12 16.16.25 ?

What I have tried:

public struct PLAT_SUBSCRIBE_EVENT_V20
 {
       [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public char[]
       szAlarmTime;
  }


public void CB_SubscribeEvent(PLAT_SUBSCRIBE_EVENT_V20 pstEvent, IntPtr pUser)
{
           byte[] _szAlarmTime = Encoding.Default.GetBytes(pstEvent.szAlarmTime);
            string __szAlarmTime = Encoding.Default.GetString(ar);
}



but  __szAlarmTime = \0\0\0\0\0\0\0\0??;\b\0\0\0\0?????qUw?g?\u0001\0\0\0\0"

\0\0\0\0\0\0\0\0??;\b\0\0\0\0?????qUw?g?\u0001\0\0\0\0 its not humman readable data.
so what will be do for write Data
i want this type of data 2018-03-12 16.16.25 ?
Posted
Updated 13-Mar-18 1:54am
v7
Comments
PIEBALDconsult 9-Mar-18 8:19am
   
Looks OK to me. What makes you think it's wrong?
Richard MacCutchan 12-Mar-18 8:16am
   
Your code does not make sense. You have three versions of the string: __szAlarmTime, _szAlarmTime and szAlarmTime. But you are not explaining where these strings come from, or what they are supposed to represent. Please update your question with more detail.

1 solution

The chances are that the conversion is working perfectly - but the input is not what you expected, so the output doesn't look like a "readable string". I'd start by looking at where you get the pst.Event.szAlarmTime from and look at the definition in any documentation with that. The chances are that it's not a human readable alarm time at all, but an encoded DateTime start, a repeat value and / or an end value which you will need to process in much better detail to get a human readable value from.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900