public static String StringToHex(String sString)
{
if (sString.Length == 0) { return ""; }
StringBuilder sb = new StringBuilder(sString.Length * 2);
Char[] chars = sString.ToCharArray();
String T = "";
foreach (Char c in chars)
{
T = "0" + Convert.ToString(c, 16).ToUpper();
sb.Append(T.Substring (T.Length -2 ));
}
return sb.ToString();
}Sorry, did not understand from your code what is this function suppose to
do.
Please tell us what you want to get out of the function with name
StringToHex
George.
"Edwin Knoppert" <news@.hellobasic.com> wrote in message
news:43f5dbbb$0$2025$ba620dc5@.text.nova.planet.nl...
> public static String StringToHex(String sString)
> {
> if (sString.Length == 0) { return ""; }
> StringBuilder sb = new StringBuilder(sString.Length * 2);
> Char[] chars = sString.ToCharArray();
> String T = "";
> foreach (Char c in chars)
> {
> T = "0" + Convert.ToString(c, 16).ToUpper();
> sb.Append(T.Substring (T.Length -2 ));
> }
> return sb.ToString();
> }
>
Don't let the unicode string fool you.
Just wanted to convert a string (with ansi chars) to two-byte hex notation.
Using a string for in and out is simply convienant.
The VB part has an Hex() function, c has value converters.
"George Ter-Saakov" <gt-nsp@.cardone.com> schreef in bericht
news:uOEDc89MGHA.1028@.TK2MSFTNGP11.phx.gbl...
> Sorry, did not understand from your code what is this function suppose to
> do.
> Please tell us what you want to get out of the function with name
> StringToHex
>
> George.
> "Edwin Knoppert" <news@.hellobasic.com> wrote in message
> news:43f5dbbb$0$2025$ba620dc5@.text.nova.planet.nl...
>
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment