Using hex as delimitor when splitting string
I am reading a string of a socket. The sting contains key-value pairs using the hex 0x0开发者_开发技巧1 as delimitor. I would like to split the string to get the pairs, but can't quite get my head around it.
Any help would be greatly appreciated.
.NET/C#. Framework 4.
Given a string input
, you can split it using the Split
method:
string[] splitted = input.Split(new char[] { (char)0x01});
You might want to use StringSplitOptions.RemoveEmptyEntries
as well to remove any elements not containing any readable char.
精彩评论