Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Japansese characters offset problem

Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have a problem in reading the japanese chracters from the form element. Acutally from one parameter I am reading the values like this

String strDetails = Request.getParameter("Details");
If that form field has only japanese character then everything is coming fine. But the requirements is it will have many details like Slno, Name,Address etc. I am getting that in the string and using the offset only i am identifying the parameters. Say slno will be from 1 to 2 and name will be in 3 to 20 and Address will be in 30 to 60.

I am separating the parameter like this.

String strNo = strDetails.subString(0,2);
String strUserName = strDetails.subString(2,20);
String strAddress = strDetails.subString(20,30);

The problem is like when i use the offset to get the values from the string the offset is getting changed if the request is coming from another (japanese)server. But when they print the request that have sent it is coming fine which means the offset is correct at their end including the japanese characters. But when it reaches the servlet then the offset is getting changed.

In detail if they send some 10 japanese characters it is coming here as 5 but the characters are same. I think this is problem due to double byte. They are sending Kanji characters. Instead of getting japanese characters i am also getting the some charaters from the address field also.

like if they send request like


where XXXX is japanese characters (kanji)

while it reaches my server i am getting the request like this


So when I try to get the values using the offset i am not able to get the values properly because of the offset. But when i try to print the values in the page it is coming fine.

Please help me how to resolve it.

Thanks in advance

Die Fledermaus does not fear such a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic