943,865 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 556
  • Java RSS
Jun 15th, 2009
0

Views and Suggestions on Unicode

Expand Post »
Hello,

I just discovered that we can use unicode anywhere in the program.

EG :
java Syntax (Toggle Plain Text)
  1. public class CheckUnicode {
  2. public static void m\u0061in(String\u005B\u005D args) {
  3. System.out.println("Hello World!");
  4. }
  5. }
\u0061 = 'a' .. \u005B = '[' .. \u005D = ']'

This program will execute fine without any errors.

But what i want to know is, Whats the benefit of using unicode in program ?

Waiting for your views and suggestions.

Regards,
Similar Threads
Reputation Points: 51
Solved Threads: 24
Junior Poster
puneetkay is offline Offline
122 posts
since Nov 2007
Jun 15th, 2009
0

Re: Views and Suggestions on Unicode

You may need unicode to print characters that are not supported. Like having an application that needs to print messages in various languages (English, German, Chinese) depending on user's selection.

It is used for internationalization. In one of my projects we had different property files used for resource bundles to print messages in different languages. For languages like English, French we had normal characters, but for Chinese and others we used unicode.

Unicode is also used for printing unsupported characters in HTML pages

But even if you can use it for declaring methods, you shouldn't. It is better to declare methods and variables with English characters and English descriptions since it may be read by others.

Meaning that you should name a method like:
> getNumberOfUsers

but not:
> epestrepseArithmoChriston

The later translates to the first method but you shouldn't name methods using your native language with english characters. Someone else might want to read the code.

It happened to me where we had to debug an entire application written in Italian. Not a clue what was going on. Babel Fish became my best friend
Last edited by javaAddict; Jun 15th, 2009 at 6:46 am.
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,259 posts
since Dec 2007
Jun 15th, 2009
1

Re: Views and Suggestions on Unicode

The ability to use any character regardless of the current system character set.

Be careful though. Unicode is translated as the first step in compilation, so you might wind up with some unforeseen complications.

See http://en.wikibooks.org/wiki/Programming:Java_Comments
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Jun 15th, 2009
0

Re: Views and Suggestions on Unicode

Thanks for reply,
Ok, Got it.

So can we say, we use unicode in comments, method names and variable names to create a better documentation in native languages?

Or is there any other reason too ?
Reputation Points: 51
Solved Threads: 24
Junior Poster
puneetkay is offline Offline
122 posts
since Nov 2007
Jun 15th, 2009
1

Re: Views and Suggestions on Unicode

Click to Expand / Collapse  Quote originally posted by javaAddict ...
But even if you can use it for declaring methods, you shouldn't. It is better to declare methods and variables with English characters and English descriptions since it may be read by others.
No you shouldn't use unicode for declaring methods and variables.
You use unicode for unsupported characters. If your keyboard has the 'a' then use it for the name of your method. What's the point to use unicode then
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,259 posts
since Dec 2007
Jun 15th, 2009
0

Re: Views and Suggestions on Unicode

Click to Expand / Collapse  Quote originally posted by javaAddict ...
No you shouldn't use unicode for declaring methods and variables.
You use unicode for unsupported characters. If your keyboard has the 'a' then use it for the name of your method. What's the point to use unicode then
Yes, Thats what i actually wanted to say.

Thanks for help!
Reputation Points: 51
Solved Threads: 24
Junior Poster
puneetkay is offline Offline
122 posts
since Nov 2007
Jun 15th, 2009
0

Re: Views and Suggestions on Unicode

Actually what I said is what I believe to be best practice. In general, you can do whatever you want.
But I doubt if anyone will write an entire application using only unicode. Can you imagine?
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,259 posts
since Dec 2007
Jun 15th, 2009
0

Re: Views and Suggestions on Unicode

Click to Expand / Collapse  Quote originally posted by javaAddict ...
Actually what I said is what I believe to be best practice. In general, you can do whatever you want.
But I doubt if anyone will write an entire application using only unicode. Can you imagine?
Well, maybe the people who write poetry in Perl (which then also must be functional code to qualify), yes, I can imagine.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Jun 15th, 2009
0

Re: Views and Suggestions on Unicode

Click to Expand / Collapse  Quote originally posted by javaAddict ...
Actually what I said is what I believe to be best practice. In general, you can do whatever you want.
But I doubt if anyone will write an entire application using only unicode. Can you imagine?
LOL, We will need to develop a special application to read and write applications in that such way.
Reputation Points: 51
Solved Threads: 24
Junior Poster
puneetkay is offline Offline
122 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Powers
Next Thread in Java Forum Timeline: Arrays





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC