Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

French string comparison  RSS feed

 
Kevin manoj
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In order to validate the URL parameters, I created an String array in JSP. Only values in the array are allowed.

My problem is when strings contain some french character, equals method does not work.

For example:
strParameter = (String)request.getParameter("AAA");
...
String[] strArray= {"BBB", "Mobilit�","CCC" ... };

if strParameter is "Mobilit�", the weird thing is that when I use following code to search the match in array:

for (int i=0; i<strArray.length; i++){
if (strParameter.equals(strArray[i])
break;
}

the code does not work.

I print out the bytes (UTF-8):
strParameter : 77 111 98 105 108 105 116 -61 -87
strArray[1] : 77 111 98 105 108 105 116 -17 -65 -67

The only difference is the character �. It may be encoded in different character set.

My question is how to define the string(Mobilit�) in an array to make it match the URL parameter ?

Thanks
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!