Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / March 2006

Tip: Looking for answers? Try searching our database.

Converting special characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
quindo@gmail.com - 23 Mar 2006 11:32 GMT
Hello,

I'm searching for a function in jscript to convert a special character
(like an o with an umlaut) to its html-code equivalent (ö).

Is there a function like that in Jscript?

Greetings,
Pieter
Martin Honnen - 29 Mar 2006 13:28 GMT
> I'm searching for a function in jscript to convert a special character
> (like an o with an umlaut) to its html-code equivalent (ö).
>
> Is there a function like that in Jscript?

You can implement one

String.prototype.htmlEncode = function () {
  return this.replace(/./g, function (c) { return '&#' + c.charCodeAt()
+ ';'; });
}

var s = 'ö';
s.htmlEncode()

if you want. Note that the above escapes any character, you might want
to change that depending on which characters you regard as 'special'.

And passing a function to the replace method is not supported in JScript
5 but only with JScript 5.5 and later.

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.