• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Handling special charecters in java script

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

I want to handle the special characters in java script.
Actually I am getting a string which will have the characters like < or
> or \ .
I would like to convert them into < or > or \\ respectively.
I am trying to search a generic library function which can do this for me.
A simple thing is what I can do is to use string.replace("\", "\\");
But i dot want to do that, I need a generic function which can handle all of these special chars in one function call.

Could and one please help me out.
 
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There isn't a builtin one. You'll need to write one yourself.
[ August 05, 2008: Message edited by: Bear Bibeault ]
 
AmitDBond Sethi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

My Last post was a bit unclear, so posting again, please ignore the space after & sign while reading, as i knowingly added that space so that it does not convert the & lt; to < sign.

I want to handle the special characters in java script.
Actually I am getting a string which will have the characters like & lt; or
& gt; or & #092;
I would like to convert them into < or > or \ respectively.
I am trying to search a generic library function which can do this for me.
A simple thing is what I can do is to use string.replace("& #092;", "\");
But i dot want to do that, I need a generic function which can handle all of these special chars in one function call.
 
Bear Bibeault
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understood your question completely. The answer remains the same.
 
AmitDBond Sethi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh is it. In that case I will go ahead and write my own function.
Thanks
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic