Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

unicode character

 
cybel sheriden
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

this is a incomplete Q please ignore.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic