Thread View: borland.public.jbuilder.java.language
7 messages
7 total messages
Started by Bernie Hunt
Sat, 23 Sep 2006 16:24
Convert ASCII Code to String
Author: Bernie Hunt
Date: Sat, 23 Sep 2006 16:24
Date: Sat, 23 Sep 2006 16:24
17 lines
1303 bytes
1303 bytes
I've got an int that holds the ASCII code for a charactor and I need to convert that to the char represented by that ASCII code. Example; int myInt char myChar myInt = 68 // Ascii code for "D" myChar = needs to be a D But I haven't been able to figure out how to make that happen. I've found a couple of ways to make myChar a string equal to 68, hahahaha but not quite what I need. I'm working around external data and other people's code so I don't really have the option to go back and start in a better way. Can anyone help with how to assign the ASCII code in a int to a char? Thanks, Bernie
Re: Convert ASCII Code to String
Author: Mehmet F. Erten
Date: Sat, 23 Sep 2006 16:52
Date: Sat, 23 Sep 2006 16:52
13 lines
1402 bytes
1402 bytes
String [] asciiCharacters = new String [] {65 other-values, "A", "B", "C",
"D");
0 is the first value (starting) in the array.....
fist array value can be a blank....
myChar = asciiCharacters[myInt];
you can use the following sites to build your asciiCharacters
http://www.walthowe.com/navnet/faq/ascitabl.html
http://www.newebgroup.com/academy/tables/ascii.htm
Re: Convert ASCII Code to String
Author: Bernie Hunt
Date: Sat, 23 Sep 2006 17:09
Date: Sat, 23 Sep 2006 17:09
37 lines
1829 bytes
1829 bytes
Mehmet,
Thanks for the quick reply. I take it there is no way to directly convert
without the over head of a table? There is a way to get the ASCII code
from a charactor in Java, I figured there must be a way to turn an ASCII
code back into a charactor.
Bernie
"Mehmet F. Erten" <mehmet_erten@mblsoft.com> wrote in
news:45156632@newsgroups.borland.com:
> Subject: Re: Convert ASCII Code to String
> From: "Mehmet F. Erten" <mehmet_erten@mblsoft.com>
> Newsgroups: borland.public.jbuilder.java.language
> Reply-To: "Mehmet F. Erten" <mehmet_erten@mblsoft.com>
>
> String [] asciiCharacters = new String [] {65 other-values, "A", "B",
> "C", "D");
>
> 0 is the first value (starting) in the array.....
> fist array value can be a blank....
>
> myChar = asciiCharacters[myInt];
>
> you can use the following sites to build your asciiCharacters
>
> http://www.walthowe.com/navnet/faq/ascitabl.html
>
> http://www.newebgroup.com/academy/tables/ascii.htm
>
>
>
>
>
Re: Convert ASCII Code to String
Author: Michael R. Rottmeier
Date: Sat, 23 Sep 2006 17:27
Date: Sat, 23 Sep 2006 17:27
48 lines
2363 bytes
2363 bytes
Hi Bernie,
In Delphi we have the function Chr() which returns the string of a given
decimal code point, so Chr(68) would return "D".
Have you looked if Java does offer something similar?
Best wishes,
Michael
Bernie Hunt schrieb:
> Mehmet,
>
> Thanks for the quick reply. I take it there is no way to directly convert
> without the over head of a table? There is a way to get the ASCII code
> from a charactor in Java, I figured there must be a way to turn an ASCII
> code back into a charactor.
>
> Bernie
>
>
>
> "Mehmet F. Erten" <mehmet_erten@mblsoft.com> wrote in
> news:45156632@newsgroups.borland.com:
>
>> Subject: Re: Convert ASCII Code to String
>> From: "Mehmet F. Erten" <mehmet_erten@mblsoft.com>
>> Newsgroups: borland.public.jbuilder.java.language
>> Reply-To: "Mehmet F. Erten" <mehmet_erten@mblsoft.com>
>>
>> String [] asciiCharacters = new String [] {65 other-values, "A", "B",
>> "C", "D");
>>
>> 0 is the first value (starting) in the array.....
>> fist array value can be a blank....
>>
>> myChar = asciiCharacters[myInt];
>>
>> you can use the following sites to build your asciiCharacters
>>
>> http://www.walthowe.com/navnet/faq/ascitabl.html
>>
>> http://www.newebgroup.com/academy/tables/ascii.htm
>>
>>
>>
>>
>>
>
Re: Convert ASCII Code to String
Author: Arthur Ore
Date: Sat, 23 Sep 2006 22:27
Date: Sat, 23 Sep 2006 22:27
36 lines
2011 bytes
2011 bytes
Hi Bernie,
You haven't said why having myChar=68 is "not quite what you want you need"
for a "D"
Does the following code do help with what you want?
for (int i=0; i<256; i++)
{
System.out.println("i=" + i + ", " + (char) i);
}
It simply casts the int to a char
Arth
"Bernie Hunt" <bhunt@optonline.net> wrote in message
news:Xns98477E3712C1Bbhuntoptonlinenet@207.105.83.66...
> I've got an int that holds the ASCII code for a charactor and I need to
> convert that to the char represented by that ASCII code. Example;
>
> int myInt
> char myChar
> myInt = 68 // Ascii code for "D"
> myChar = needs to be a D
>
> But I haven't been able to figure out how to make that happen. I've found
> a
> couple of ways to make myChar a string equal to 68, hahahaha but not quite
> what I need. I'm working around external data and other people's code so I
> don't really have the option to go back and start in a better way.
>
> Can anyone help with how to assign the ASCII code in a int to a char?
>
> Thanks,
> Bernie
Re: Convert ASCII Code to String
Author: Bernie Hunt
Date: Sun, 24 Sep 2006 01:10
Date: Sun, 24 Sep 2006 01:10
61 lines
2389 bytes
2389 bytes
Arthur,
Please arrange for my stupid sign to be shipped to my work address. I
will affix it to my forehead as soon as it arrives.
I was trying
myChar = char(myInt);
rather than
myChar = (char) myInt;
Thanks to all for your paitent assistance!
Friends don't let friends code when they are tired!
Bernie
"Arthur Ore" <arthur_dot_ore@nospamthx_zen_dot_co.uk> wrote in
news:4515b4d6@newsgroups.borland.com:
> Hi Bernie,
>
> You haven't said why having myChar=68 is "not quite what you want you
> need" for a "D"
>
> Does the following code do help with what you want?
>
> for (int i=0; i<256; i++)
> {
> System.out.println("i=" + i + ", " + (char) i);
> }
>
> It simply casts the int to a char
>
> Arth
>
> "Bernie Hunt" <bhunt@optonline.net> wrote in message
> news:Xns98477E3712C1Bbhuntoptonlinenet@207.105.83.66...
>> I've got an int that holds the ASCII code for a charactor and I need
>> to convert that to the char represented by that ASCII code. Example;
>>
>> int myInt
>> char myChar
>> myInt = 68 // Ascii code for "D"
>> myChar = needs to be a D
>>
>> But I haven't been able to figure out how to make that happen. I've
>> found a
>> couple of ways to make myChar a string equal to 68, hahahaha but not
>> quite what I need. I'm working around external data and other
>> people's code so I don't really have the option to go back and start
>> in a better way.
>>
>> Can anyone help with how to assign the ASCII code in a int to a char?
>>
>> Thanks,
>> Bernie
>
>
Re: Convert ASCII Code to String
Author: Gillmer J. Derge [TeamB]
Date: Mon, 25 Sep 2006 04:29
Date: Mon, 25 Sep 2006 04:29
13 lines
1272 bytes
1272 bytes
Bernie Hunt wrote: > I've got an int that holds the ASCII code for a charactor and I need to > convert that to the char represented by that ASCII code. Example; > > int myInt > char myChar > myInt = 68 // Ascii code for "D" > myChar = needs to be a D myChar = (char)myInt; -- Gillmer J. Derge [TeamB]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads