|
-
Jun 13th, 2007, 03:57 AM
#1
Thread Starter
Addicted Member
ChrW()
Dear Java developer,
I am VB.net developer and now i try to study java.
in VB.net, there is a function ChrW() that convert from Unicode code to the Character. ex. ChrW(65) it will return A.
Is there any function in Java similar to this function?
Thirith
ជីន ច័ន្ទធិរិទ្ធ៖ពេលវេលាពុំដែលរង់ចាំអ្នកឡើយ!Time never wait you!
-
Jun 14th, 2007, 12:53 AM
#2
Re: ChrW()
A direct cast should do the trick for you
Code:
char ch = (char) 65;
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 14th, 2007, 05:17 AM
#3
Thread Starter
Addicted Member
Re: ChrW()
 Originally Posted by ComputerJy
A direct cast should do the trick for you
Code:
char ch = (char) 65;
Thank you,
what about the Unicode? Unicode have 2 bytes, 4 bites. It can work with this type.
ជីន ច័ន្ទធិរិទ្ធ៖ពេលវេលាពុំដែលរង់ចាំអ្នកឡើយ!Time never wait you!
-
Jun 14th, 2007, 10:24 AM
#4
Re: ChrW()
Characters in java are stored as Unicode by default, but in the case of casting from an integer to an char the integer value is considered ASCII code
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 17th, 2007, 10:39 PM
#5
PowerPoster
Re: ChrW()
Java's Unicode escape sequences are in the form '\uXXXX'.
If you are using Java 1.4 or earlier then the 's.length()' gives the number (16 bit) of characters in a string or a single character. Characters with Unicode values greater than '\uFFFF' cannot be represented.
If you are using Java 1.5 string/character representing on UTF-16 encoding. So you can read characters above '\uFFFF' , as pairs of characters .
To determine the length of such a string/character,
Code:
int length = Character.codePointCount (str, 0, str.length ());
Read the Java 5 documentation to find more about the code point scheme.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
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
|