|
-
May 17th, 2007, 04:00 PM
#1
Thread Starter
Fanatic Member
text to Ascii and back again.
Hi all,
Im working on a project and i need to conver text to a numeric value and back again so i figured i would use Ascii
what i hope to do is something like this webpage
http://getyourwebsitehere.com/jswb/text_to_ascii.html
I hope to convert something like "test"
to &# 116; &# 101;& # 120; &# 116;
text and then remove the &#
(added spaces so it will display)
-
May 17th, 2007, 06:12 PM
#2
Re: text to Ascii and back again.
C# Code:
myInt = Convert.ToInt32(myChar);
myChar = Convert.ToChar(myInt);
That will convert char objects to their Unicode values and back again.
-
May 17th, 2007, 08:09 PM
#3
Thread Starter
Fanatic Member
Re: text to Ascii and back again.
 Originally Posted by jmcilhinney
C# Code:
myInt = Convert.ToInt32(myChar);
myChar = Convert.ToChar(myInt);
That will convert char objects to their Unicode values and back again.
Ill give it a try thanks
-
May 17th, 2007, 08:16 PM
#4
Thread Starter
Fanatic Member
Re: text to Ascii and back again.
unicode is not a uniform lenght?
-
May 17th, 2007, 08:41 PM
#5
Re: text to Ascii and back again.
Unicode uses two bytes per character, while ASCII only use one byte. ASCII was inadequate because one byte can only have 256 values. Unicode can have 65536 different characters while ASCII can have only 256. Unicode uses the same numeric value as ASCII for most ASCII characters, but there is a block where they do not coincide. Those are less-used characters though. All the letters numbers and common punctuation characters have the values in ASCII and Unicode.
-
May 21st, 2007, 07:34 PM
#6
Thread Starter
Fanatic Member
Re: text to Ascii and back again.
I am trying to keep the number down to the smallest possible.
is there anyway to get the value of the bytes in binary to a string
like 1=0001 2=0010 for ascii?
-
May 21st, 2007, 07:54 PM
#7
Re: text to Ascii and back again.
I'm not 100% sure what you mean. Convert.ToInt32 returns an Integer value. If you want to convert that, or any, integer to a binary string you use the Convert.ToString method, e.g.
c# Code:
char character = 'A';
int unicodeValue = Convert.ToInt32(character);
string binaryString = Convert.ToString(unicodeValue, 2).PadLeft(16, '0');
unicodeValue = Convert.ToInt32(binaryString, 2);
character = Convert.ToChar(unicodeValue);
-
May 21st, 2007, 09:24 PM
#8
Thread Starter
Fanatic Member
Re: text to Ascii and back again.
I'm trying to take a string and create a numeric value that i can encrypt
then later decrypt it and turn it back into a string
obviously the smaller the numeric value the easier it will be for me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|