What is the 'whitespace' ASCII or Unicode character in System.Text.Encoding.ASCII.GetBytes(whitespace)
- I would like to pass a whitespace character by using the System.Text.Encoding.ASCII.GetBytes(" "), and System.Text.Encoding.Unicode.GetBytes(" ") , where " " is the whitespace Character required. What do I need to type (" ") to get a whitespace character passed.?
All Replies
0x20
%20%
something like that see here
If you're not living on the edge, you're taking up too much room- I need to find out what do I place into the ....GetBytes( .... ).... With ASCII usually GetBytes( chr(20) ) but I got no white space. Any alternatives in Unicode?
- You should post your code, because it is not clear what you want, and why you need to do it this way.
First, whitespace is the same, UNICODE or ASCII. The only difference is the size of a character, 8/16 bits. This should do what you have asked:
Dim mybytes() As Byte
mybytes = System.Text.Encoding.ASCII.GetBytes(Chr(32))
btw, ASCII 20 is DC4, a device control byte...not going to advance your cursor, so...it is not the same whitespace as you assume. (You intended SPACE, which is &H20, or 32.)- Edited byjinzai Wednesday, November 04, 2009 4:50 PMadd comment about space
The context is as follows:
Protected Overrides Function OnRequest(ByVal conversation As DdeConversation, ByVal item As String, ByVal format As Integer) As RequestResult
Console.WriteLine("OnRequest:".PadRight(16) _
+ " Service='" + conversation.Service + "'" _
+ " Topic='" + conversation.Topic + "'" _
+ " Handle=" + conversation.Handle.ToString() _
+ " Item='" + item + "'" _
+ " Format=" + format.ToString())' Return data to the client only if the format is CF_TEXT.
If format = 1 Then
Return New RequestResult(System.Text.Encoding.ASCII.GetBytes("time=" + datetime.now.tostring() + convert.tochar(0)))
End If
Return RequestResult.NotProcessed
Extract Taken from NDde codeplex Server sample. The underlying text is sent to the DDE client. What is required is a white space to be sent.I do not believe that whitespace is your issue, and attempting to add a terminator to an already terminated string will not help.
I think that your issue relates to the byte array returned by the ASCII encoder. As written, you do not have ready access to the string that was returned by the DataTime object, and it is already a string...it should not need a terminator.
btw, the terminator, which always has the value 0, is not whitespace. Again, whitespace is a non-printing character that also advances the cursor in some manner, like TAB, SPACE, CR, LF, etc.
Here is one of many ways to get that time string constructed: (Notice the whitespace added to the strings...vbCrLf is a single carriage return and line feed.)Dim test() As Byte = _ System.Text.Encoding.ASCII.GetBytes(DateTime.Now) Dim teststr As String = "Time=" Dim j As Integer For j = 0 To test.Length - 1 teststr += Chr(test(j)) Next ' Whatever your program is set for...UNICODE by default. Dim easierstr As String = "Time=" + DateTime.Now MsgBox("ASCII : " + teststr + vbCrLf + "UNICODE : " + easierstr, _ MsgBoxStyle.Information)- Edited byjinzai Thursday, November 05, 2009 3:36 PMformatting
"Time=" + DateTime.Now.ToString() + Convert.ToChar(0) this is the text that I would like to replace with a whitespace to send to the DDE client. When I sent the Chr(32) an empty set, not an advanced cursor was sent. Thus, the result is () and not ( ). I am trying to mirror a result set sent to the DDE client, not knowing the precise makeup of the packet.


