Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > writing in html...

Reply
Thread Tools

writing in html...

 
 
Bad_Kid
Guest
Posts: n/a
 
      07-07-2004
how can I write text (chars) through numbers - (using ascii table)?? -
whaat's the function that does conversion int-> char?


 
Reply With Quote
 
 
 
 
Grant Wagner
Guest
Posts: n/a
 
      07-07-2004
Robert wrote:

> In article <ccfm4a$rcs$(E-Mail Removed)>,
> "Bad_Kid" <(E-Mail Removed)> wrote:
>
> > how can I write text (chars) through numbers - (using ascii table)?? -
> > whaat's the function that does conversion int-> char?

>
> var i = 1;
>
> alert(""+i);
>
> In the case where you concatenate a string to a number, the result will
> be a string.
>
> alert(i);
>
> In most instances, JavaScript will correctly convert a number from
> integer to character as you expect.
>
> Robert


I think what he means is he has int values between 65 and 90 inclusive (for
example), and wants to output the characters those integer values represent
in the "ascii" table.

To do that, he needs the static fromCharCode() method of the String object:

<script type="text/javascript">
for (var i = 65; i <= 90; i++) {
document.write(String.fromCharCode(i) + '<br>');
}
</script>

--
| Grant Wagner <(E-Mail Removed)>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html


 
Reply With Quote
 
 
 
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      07-11-2004
Bad_Kid wrote:
> how can I write text (chars) through numbers - (using ascii table)?? -
> whaat's the function that does conversion int-> char?


All numbers in ECMAScript and its implementations are double-precision
(64 bit) floating-point numbers. There are no real integers like in C
etc. and there is no "int" or "char" type ("char"s are strings of length
1). However, if you regard a floating-point number with a fractional
part of zero an integer value, then

String.fromCharCode(integer_value)

will use not only US-ASCII (7 bit) but also either ISO-8859-1 (8 bit),
the character encoding of the current locale or Unicode (UTF-16, 16
bit), depending on the implementation. Another way are string literals
where the same applies:

"\x20"

equals the space character (" ") and

"\u20AC"

equals the Euro sign as of Unicode.

This is a very basic question, please read the
guides and specs before you post next time.

The ECMAScript specifications are available at
<http://www.mozilla.org/js/language/>

JavaScript Guides and References are available at
<http://devedge.netscape.com/central/javascript/>

The JScript Reference is available at
<http://msdn.microsoft.com/library/>

See the FAQ <http://jibbering.com/faq/> which is
posted here regularly.


HTH

PointedEars
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing a program to create a wireless connection. =?Utf-8?B?bWJvd3llckBwdXJkdWUuZWR1?= Wireless Networking 1 10-05-2005 12:59 PM
writing email problems? Bri Firefox 1 05-12-2005 03:03 AM
Any problems with writing the information into a file - Multi-users perform writing the same file at the same time ???? HNguyen ASP .Net 4 12-21-2004 01:53 PM
Unhandled exception in FileStream when writing to a full disk - bug in framework? Amit ASP .Net 8 08-04-2003 03:34 PM
A failure occurred writing to the resources file. Access is denied. -- RESX file is locked? -- WHY? Mark Kamoski ASP .Net 1 07-04-2003 12:02 PM



Advertisments