• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Character handling

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing this problem in handling abnormal characters [cyrillic]

Hashtable hash=new Hashtable();

hash.put("ӓ","a");
hash.put("Ӓ","A");

System.out.println(hash.get("ӓ"));
System.out.println(hash.get("Ӓ"));

Both of the above line returns 'A'
I am using jdk 1.4.

Pls help me,

Thanks
Akilan
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Akilan!

Analyzing the code you've wrote, seems that both 'A' and 'a' are being added to the Hashtable at the same index key. So, only the last 'A' will remain referenced.
But, about the abnormal characters, it can be some limitations of the editor you are using the write java codes.
This kind of characters "Ӓ" are really not common.

I hope have helped
 
Marshal
Posts: 28304
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Adorn", welcome to the JavaRanch.

We're glad to have you here, but we do require members to have valid display names.

Display names must include your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like there's some confusion here caused by different encodings, and the fact that different browsers are rendering special characters differently. Here is what I think Akilan typed:

Some people may see it rendered like this:

While others see:

Now the thing is, if I take the first version of this code and run it, I get output of a and A, as expected. If that's not what Akilan is seeing... I think maybe Akilan's code is something different from my first guess above. Akilan, does your code match one of the versions I've shown above? If not, it might be easiest if you email me the lines of code, so I can see what you're really doing here without interference from web browsers.
[ July 19, 2006: Message edited by: Jim Yingst ]
 
Daniel Adornes
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Clapham:
"Adorn", welcome to the JavaRanch.

We're glad to have you here, but we do require members to have valid display names.

Display names must include your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted.




Hi Paul!

Sorry, I didn't know about that!
Now I think it's ok!
 
akilan irudaya raja
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Daniel Adornes,

Your analysis is correct. When I use eclipse I am getting this problem.
it saves abnormal character as ?.

Dear Jim,

I admire ur knowledge. My indended code is like second code snippet.
even I do it in notepad(MS-Windows) I am facing the same problem .Moreover javac does not comple the file in Unicode format. So what will be the correct editor, so how we can handle special characters in Java.
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Akilan - okay. Just ignore my first code sample; I thought maybe you were doing something different. From your description, this isn't necessarily a problem with Eclipse; it may also be a problem with the way your computer is set up, or with how you are getting these special characters. Are you copying/pasting from somewhere else? Never mind - even if you get the characters into eclipse and into the Java source correctly, there's a good chance that someone else who views the source code may not see it correctly unless their system is set up just right. So I recommend inside Java source, do not use any characters outiside the standard ASCII range 0-127. Instead, if you need to represent other characters you can use Unicode escapes:

I got the hex values for those characters from the Cyrillic code chart at www.unicode.org .
 
akilan irudaya raja
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jim,

I saved the program in Unicode format in MS-Notepad.
I compiled using javac -encoding Uncode.

Now it works.

Thanks a lot,
Akilan
 
Die Fledermaus does not fear such a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic