Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A function to convert extended character ?

277 views
Skip to first unread message

Olive

unread,
Oct 2, 1998, 3:00:00 AM10/2/98
to
Hello,

Does anybody know a javascript function wich permits
to convert extended character like é, ä... in their ascii code ?

Thanks for your answer.

Olivier


-**** Posted from Supernews, Discussions Start Here(tm) ****-
http://www.supernews.com/ - Host to the World's Discussions & Usenet

Martin Honnen

unread,
Oct 4, 1998, 3:00:00 AM10/4/98
to
Olive wrote:
>
> Hello,
>
> Does anybody know a javascript function wich permits
>
> to convert extended character like é, ä... in their ascii code ?

I don't think ascii covers this characters but get the ISO-Latin-1 code with
"é".charCodeAt()
"ä".charCodeAt()
You can use unicode escape sequences now to generate characters
"\u00E9"
"\u00E4"

> Thanks for your answer.
>
> Olivier
>
> -**** Posted from Supernews, Discussions Start Here(tm) ****-
> http://www.supernews.com/ - Host to the World's Discussions & Usenet

--

Martin Honnen

Email: mailto:Martin...@sector27.de
WWW : http://www.sector27.de/martin.honnen/

Martin Honnen

unread,
Oct 4, 1998, 3:00:00 AM10/4/98
to Olivier Fernandez
Olivier Fernandez wrote:
>
> Martin,
>
> Thanks for yor answer...but my explication was bad...
> In fact I'm searching a JavaScript function wich permits to transform extender
> char in their html code like for example:
>
> é in é or û in û...

Define an associative array which maps the character in unicode representation
to the symbolical html entity:

var jsUnicode2htmlEntity = new Object();
jsUnicode2htmlEntity["\u00E9"] = "é"
jsUnicode2htmlEntity["\u00E4"] = "ä"

As there a numerical (character code) entities in html it suffices to use

function htmlEntity (c) {
if (typeof c == "string")
c = c.charCodeAt();
return "&#" + c + ";";
}

where for example
htmlEntity ("\u00E9")
yields
é

if you just want to convert a javastring character represenation to an html
character representation.

> Do you have any idea about this ?
>
> Thanks a lot.
>
> Oliver
>
> Martin Honnen a écrit:


>
> > Olive wrote:
> > >
> > > Hello,
> > >
> > > Does anybody know a javascript function wich permits
> > >
> > > to convert extended character like é, ä... in their ascii code ?
> >
> > I don't think ascii covers this characters but get the ISO-Latin-1 code with
> > "é".charCodeAt()
> > "ä".charCodeAt()
> > You can use unicode escape sequences now to generate characters
> > "\u00E9"
> > "\u00E4"
> >
> > > Thanks for your answer.

Keep questions in the newsgroups.

0 new messages