> Hello everybody,
>
[quoted text clipped - 3 lines]
>
> How can I get it in java?
For the benefit of those who are not familiar with VB, you should have
explained that the Chr() function takes a integer representing a char code
(which is either ASCII or ANSI, not sure), and returns the corresponding
character.
In Java, you can bypass that function altogether, and do something like:
char myChar = 2;
Which declares a character called "myChar", and assigns it the value 2.
It can simultaneously be thought of as representing the natural number 2,
and the character whose unicode is 2.
- Oliver
Mike Schilling - 05 Dec 2006 17:14 GMT
>> Hello everybody,
>>
[quoted text clipped - 16 lines]
> value 2. It can simultaneously be thought of as representing the
> natural number 2, and the character whose unicode is 2.
Note that applying this same conversion to an arbitrary integer requires a
cast:
char myChar = (int) i;
since the range of int exceeds that of char.
Danno - 05 Dec 2006 17:54 GMT
> >> Hello everybody,
> >>
[quoted text clipped - 23 lines]
>
> since the range of int exceeds that of char.
I think you meant to do
char myChar = (char) i; // whereas i is an integer;
Mike Schilling - 05 Dec 2006 23:23 GMT
>> Note that applying this same conversion to an arbitrary integer requires
>> a
[quoted text clipped - 7 lines]
>
> char myChar = (char) i; // whereas i is an integer;
You are of course correct.
Danno - 05 Dec 2006 18:10 GMT
> >> Hello everybody,
> >>
[quoted text clipped - 23 lines]
>
> since the range of int exceeds that of char.
Actually, now that I think about it....you don't need a cast at all.
It will automatically accept any number from 0-65535 without a cast.
Lew - 05 Dec 2006 18:29 GMT
>> char myChar = (char) i;
>>
[quoted text clipped - 3 lines]
>
> It will automatically accept any number from 0-65535 without a cast.
Which cannot be determined at compile time. You need the cast.
- Lew
Danno - 05 Dec 2006 20:19 GMT
> >> char myChar = (char) i;
> >>
[quoted text clipped - 7 lines]
>
> - Lew
char myChar = 2; //as stated a few messages up works, that's what I
was referring to
int a = 123;
char myChar2 = (char) 2; //does require a cast
Just to clarify.
Oliver Wong - 05 Dec 2006 21:50 GMT
>> >> char myChar = (char) i;
>> >>
[quoted text clipped - 13 lines]
>
> Just to clarify.
I'm guessing you meant:
int a = 123;
char myChar2 = (char) a; //does require a cast
=)
- Oliver
Danno - 06 Dec 2006 04:59 GMT
> >> >> char myChar = (char) i;
> >> >>
[quoted text clipped - 22 lines]
>
> - Oliver
Absolutely right, thanks for the help. ;)
Mike Schilling - 05 Dec 2006 23:25 GMT
>> >> Hello everybody,
>> >>
[quoted text clipped - 26 lines]
>
> Actually, now that I think about it....you don't need a cast at all.
You do when using a variable.
> Hello everybody,
>
[quoted text clipped - 3 lines]
>
> How can I get it in java?
(char) 2

Signature
simon@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
;; lovely alternative to rice.
> Hello everybody,
>
[quoted text clipped - 6 lines]
> thank you
> bye
No function necessary:
char ch = '\u0002';
The \u notation requires a 4-digit hex number that represents a UTF-16
Unicode code unit.
For Unicode code points in the supplementary character planes, you must
use a CharSequence, typically a String, with the UTF-16 surrogate pairs:
String str = "\uXXXX\uYYYY"; // XXXX is a leading surrogate value; YYYY
is a trailing surrogate value
Regards,
John O'Conner