This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes unicode character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "unicode character" Watch "unicode character" New topic
Author

unicode character

cybel sheriden
Ranch Hand

Joined: Jan 18, 2005
Posts: 50
hi

unicode character is represented by '\uxxxx'.......where xxxx is a hexadecimal no.i get an error in the following assignment

1. '\Uxxxx' replacing u with U
2. '\u000a'
3.'\u000d'
4.'\u4e' isn't 004e same as 4e, both are hex no..... or is it like the hex no should be rep by 4 digit in unicode no.
[ February 22, 2005: Message edited by: cybel sheriden ]
cybel sheriden
Ranch Hand

Joined: Jan 18, 2005
Posts: 50
hi

this is a incomplete Q please ignore.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
For future reference, you can go back and edit or delete any message you post here. You do this by clicking on the pencil-and-paper icon at the top of your message and to the far right side.

Layne


Java API Documentation
The Java Tutorial
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Hmmm...I tried to post a reply to your other message but it looks like someone deleted it. However, with the risk of confusing people, I'll still post my answer here. It might help to alleviate the confusion if you edit the above message. (Of course, you may be doing that at this exact moment...I guess we'll just see.) Without any further ado, here's my answer to your question:

In programming, 004e is NOT the same as 4e. The difference is in the amount of space that is used. Since each hexadecimal digit is equivalent to 4 binary digits (or bits), 4e only takes 8 bits or 1 byte whereas 0043 takes up 16 bits or 2 bytes.

Layne
cybel sheriden
Ranch Hand

Joined: Jan 18, 2005
Posts: 50
hi

thanks Layna......i got the answer for the 4th case of my listing wht abt the first three cases, which i got error.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
I'm not sure what the problem is for the first three. What error are you referring to? Are you talking about a compiler error? If you are compiling some sample code to investigate this, please post the code as well as the compiler error you recieve.

Also, please take the time to type out full words. Many of our members speak and write English as a second (or third or fourth language). Abbreviations can be confusing, even for native English speakers. So please type out complete words like "number" rather than using abreviations like "no".

Thanks,

Layne
cybel sheriden
Ranch Hand

Joined: Jan 18, 2005
Posts: 50
here is my line of code and the corresponding error message i got.

class test1
{

public static void main(String[] args)
{

char a='\u000d';
char b='\u000a';
char c='\U004e';


}

}


test1.java:7: illegal line end in character literal
char a='\u000d';
^
test1.java:8: illegal line end in character literal
char b='\u000a';
^
test1.java:9: illegal escape character
char c='\U004e';
^
test1.java:9: unclosed character literal
char c='\U004e';
^
test1.java:9: unclosed character literal
char c='\U004e';
^
test1.java:10: ';' expected
^
6 errors
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
If you put '\u000a' or '\u000d' in a source program, the compiler treats it as an actual line break in your program text and breaks your statement into two lines, both of which will probably have a syntax error.

You need to use '\n' or '\r'.


Mike Gershman
SCJP 1.4, SCWCD in process
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: unicode character
 
Similar Threads
Unicode Literal
Weird unicode translation problem
Unicode representation of char
d'bt REgarding Comment !!!!
Start study for SCJP