473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Convert a string?

G
Hello,

I would like to convert
string "I am a fish" into a hex string if easy?

Fairly new to .NET and have looked on google etc without much luck.

Any help appreciated,

Gary.
Mar 9 '07 #1
6 1577
What exactly do you mean by "convert...to a hex string?" Apparently, you are
referring to a string containing hexadecimal notation, but of what? A string
is a sequence of Unicode characters, unless it is in some other form of
encoding. At any rate, perhaps a statement of the purpose of this would
help.

--
HTH,

Kevin Spencer
Microsoft MVP

Help test our new betas,
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"G" <g@nospam.comwrote in message
news:80**********************************@microsof t.com...
Hello,

I would like to convert
string "I am a fish" into a hex string if easy?

Fairly new to .NET and have looked on google etc without much luck.

Any help appreciated,

Gary.

Mar 9 '07 #2
PS

"G" <g@nospam.comwrote in message
news:80**********************************@microsof t.com...
Hello,

I would like to convert
string "I am a fish" into a hex string if easy?
Say it 3 times while facing north at sunset.
>
Fairly new to .NET and have looked on google etc without much luck.

Any help appreciated,

Gary.

Mar 9 '07 #3
How about something like this (needs checking since I threw it together
pretty fast):

static string Hex(string s)
{
byte[] b = System.Text.Encoding.UTF8.GetBytes(s);
string temp="";
string s2 = "";
int i;
for (i = 0; i < b.Length; i++)
{
temp = b[i].ToString("x2");
s2+= temp;
}
return s2;
}

--Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"G" wrote:
Hello,

I would like to convert
string "I am a fish" into a hex string if easy?

Fairly new to .NET and have looked on google etc without much luck.

Any help appreciated,

Gary.
Mar 9 '07 #4
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comwrote in
message news:11**********************************@microsof t.com...
How about something like this (needs checking since I threw it together
pretty fast):
Works perfectly...
Mar 9 '07 #5
Maybe he wants something like a base64 representation of his string?

...ab

"Kevin Spencer" <un**********@nothinks.comwrote in message
news:%2***************@TK2MSFTNGP06.phx.gbl...
What exactly do you mean by "convert...to a hex string?" Apparently, you
are referring to a string containing hexadecimal notation, but of what? A
string is a sequence of Unicode characters, unless it is in some other
form of encoding. At any rate, perhaps a statement of the purpose of this
would help.

--
HTH,

Kevin Spencer
Microsoft MVP

Help test our new betas,
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"G" <g@nospam.comwrote in message
news:80**********************************@microsof t.com...
>Hello,

I would like to convert
string "I am a fish" into a hex string if easy?

Fairly new to .NET and have looked on google etc without much luck.

Any help appreciated,

Gary.


Mar 9 '07 #6
Abubakar <em**********@yahoo.comwrote:
Maybe he wants something like a base64 representation of his string?
Well, base 64 isn't hex - but the same problem would occur: base64 is a
way of representing *binary* data as text, so how does the OP want to
convert the original text to binary in the first place?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 9 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Joel Moore | last post by:
Maybe I'm just easily baffled after an all-nighter but I can't seem to figure out how to represent a BitArray as a hexadecimal string. For example: Dim outputBank As New BitArray(8) ...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
6
by: patang | last post by:
Could someone please tell me where am I supposed to put this code. Actually my project has two forms. I created a new module and have put the following code sent by someone. All the function...
3
by: GM | last post by:
Dear all, Could you all give me some guide on how to convert my big5 string to unicode using python? I already knew that I might use cjkcodecs or python 2.4 but I still don't have idea on what...
4
by: tshad | last post by:
I am trying to convert a string character to an int where the string is all numbers. I tried: int test; string stemp = "5"; test = Convert.ToInt32(stemp); But test is equal to 53.
9
by: Marco Nef | last post by:
Hi there I'm looking for a template class that converts the template argument to a string, so something like the following should work: Convert<float>::Get() == "float"; Convert<3>::Get() ==...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.