This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to handle Special Characters ?  RSS feed

 
Kaialsh Vashisth
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,
I am facing problem in handling special characters like "Más información." .suppose this word is entered in the free text box, then one way is to give error message to user by using javascript function

function isValid(delNo)
{
var ValidChars= "01234567889abcdefghijklmnopqrstuvwxyzAB...Z";
var Char;
var txtsize = delNo;
for(i = 0; i < txtsize.length; i++)
{
Char = txtsize.charAt(i);
if( ValidChars.indexOf(Char)== -1)
{
return false;
}
}
return true;
}

but i want to handle it , as user enter it should stored in database and entact displayed to user .but if i handling it using javascript for dispaly using string quotes "". it will give string terminated error.

please suggest best way to handle it.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it will give string terminated error

There is just a syntax error in your Javascript code. Writing erroneuous Javascript code in a JSP file doesn't make it a JSP problem. There's a forum devoted to Javascript here. If you have patience, maybe a moderator will move this topic sooner or later. In the future, please choose forum carefully.
 
Kaialsh Vashisth
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Bauke Scholtz ,
My dear i know there is no syntax error but the special character is creating problem.
there are some ways to handle it in java too using :

java.net.URLEncoder.encode( aString, "UTF-8" ) and
java.net.URLDecoder.decode( aString, "UTF-8" ).

but these function are not able to handle character's which are not English charset.
if i am not wrong it can be handled using StringEscapeUtils (Lang 2.3 API). which is part of java not javascript.

so the special characters can be handled on both side client as well as server.
please guys suggest me which one is good option .
1)Not accepting non English Charset
2)Handling using StringEscapeUtils

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not understand you anymore. You're mixing a lot of terms which has very little or nothing to do with each other, let alone with the given code.

Please align it all out for yourself first. Please understand what you're actually saying or thinking. Please elaborate the functional requirement in detail. Please elaborate the problem in technical details using the correct terms, preferably also using correct examples (e.g. the input and the desired output as well as the unexpected output). Please also elaborate how this is related to JSP.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!